JSTL tags not working as expected.

View: New views
5 Messages — Rating Filter:   Alert me  

JSTL tags not working as expected.

by Paulo Pinto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I think I have found out a bug, or an unexpected behaviour.

I have ported the the following code from a JSP view:

            <c:choose>
                <c:when test="${sessionScope.WW_TRANS_I18N_LOCALE=='en'}">
                    <cc:calendar id="calendar1" returnFunction="onENStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:when>
                <c:otherwise>
                    <cc:calendar id="calendar1" returnFunction="onFIStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:otherwise>
            </c:choose>


On the JSP there is no problem with the code, but with Facelets I get the "duplicate id"
error, because there are two instances of "calendar1".

The way I see it, the component tree should only have the component that was built,
depending on the "when" condition, but it seems both paths get processed.

Why does Facelets where work diferently than JSPs?

Thanks,
Paulo

Re: JSTL tags not working as expected.

by Yann Simon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/2/3 Paulo Pinto <pjmlp@...>:

> Hi,
>
> I think I have found out a bug, or an unexpected behaviour.
>
> I have ported the the following code from a JSP view:
>
>             <c:choose>
>                 <c:when test="${sessionScope.WW_TRANS_I18N_LOCALE=='en'}">
>                     <cc:calendar id="calendar1"
> returnFunction="onENStartDateSelected"
>                         size="20"
> value="#{calendarSchedulingBean.startDate}" />
>                 </c:when>
>                 <c:otherwise>
>                     <cc:calendar id="calendar1"
> returnFunction="onFIStartDateSelected"
>                         size="20"
> value="#{calendarSchedulingBean.startDate}" />
>                 </c:otherwise>
>             </c:choose>
>
>
> On the JSP there is no problem with the code, but with Facelets I get the
> "duplicate id"
> error, because there are two instances of "calendar1".
>
> The way I see it, the component tree should only have the component that was
> built,
> depending on the "when" condition, but it seems both paths get processed.
>
> Why does Facelets where work diferently than JSPs?
>
> Thanks,
> Paulo
>

Hi,

you can try with two <c:if ...>
Some tags are runtime tags, others compile-time tags.
<c:if > is a compile-time tag. It means that it will influence the
build of the JSF tree.

Yann

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: JSTL tags not working as expected.

by Paulo Pinto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I also had the same problem with <c:if/>

But shouldn't the behaviour be kept compatible with the former JSP model?

--
Paulo

On Tue, Feb 3, 2009 at 2:07 PM, Yann Simon <yann.simon.fr@gmail.com> wrote:
2009/2/3 Paulo Pinto <pjmlp@...>:
> Hi,
>
> I think I have found out a bug, or an unexpected behaviour.
>
> I have ported the the following code from a JSP view:
>
>             <c:choose>
>                 <c:when test="${sessionScope.WW_TRANS_I18N_LOCALE=='en'}">
>                     <cc:calendar id="calendar1"
> returnFunction="onENStartDateSelected"
>                         size="20"
> value="#{calendarSchedulingBean.startDate}" />
>                 </c:when>
>                 <c:otherwise>
>                     <cc:calendar id="calendar1"
> returnFunction="onFIStartDateSelected"
>                         size="20"
> value="#{calendarSchedulingBean.startDate}" />
>                 </c:otherwise>
>             </c:choose>
>
>
> On the JSP there is no problem with the code, but with Facelets I get the
> "duplicate id"
> error, because there are two instances of "calendar1".
>
> The way I see it, the component tree should only have the component that was
> built,
> depending on the "when" condition, but it seems both paths get processed.
>
> Why does Facelets where work diferently than JSPs?
>
> Thanks,
> Paulo
>

Hi,

you can try with two <c:if ...>
Some tags are runtime tags, others compile-time tags.
<c:if > is a compile-time tag. It means that it will influence the
build of the JSF tree.

Yann

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Parent Message unknown RE: JSTL tags not working as expected.

by Raymond K. DeCampo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

<c:choose>, <c:when> and <c:otherwise> are not supported in Facelets (see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl).  <c:if> is implemented as a TagHandler (see http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets) which can affect when the expression is evaluated.  Although it is difficult to see how <c:if> is giving you a duplicate id error.
 
Have you tried using the rendered attribute?

-----Original Message-----
From: Paulo Pinto [mailto:pjmlp@...]
Sent: Tuesday, February 03, 2009 07:40
To: users@...
Subject: JSTL tags not working as expected.

Hi,

I think I have found out a bug, or an unexpected behaviour.

I have ported the the following code from a JSP view:

            <c:choose>
                <c:when test="${sessionScope.WW_TRANS_I18N_LOCALE=='en'}">
                    <cc:calendar id="calendar1" returnFunction="onENStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:when>
                <c:otherwise>
                    <cc:calendar id="calendar1" returnFunction="onFIStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:otherwise>
            </c:choose>


On the JSP there is no problem with the code, but with Facelets I get the "duplicate id"
error, because there are two instances of "calendar1".

The way I see it, the component tree should only have the component that was built,
depending on the "when" condition, but it seems both paths get processed.

Why does Facelets where work diferently than JSPs?

Thanks,
Paulo

Re: JSTL tags not working as expected.

by Paulo Pinto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

for what the code is doing, the "rendered" attribute is not enough.

But now I got them working. The problem was related to the JSTL version the page was using.

The page was declaring the 1.0 version of JSTL, when I changed to the proper namespace, it
worked.

Thanks for the feedback,
Paulo


On Wed, Feb 4, 2009 at 3:19 PM, Raymond K. DeCampo <rkdecampo@...> wrote:
<c:choose>, <c:when> and <c:otherwise> are not supported in Facelets (see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl).  <c:if> is implemented as a TagHandler (see http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets) which can affect when the expression is evaluated.  Although it is difficult to see how <c:if> is giving you a duplicate id error.
 
Have you tried using the rendered attribute?

-----Original Message-----
From: Paulo Pinto [mailto:pjmlp@...]
Sent: Tuesday, February 03, 2009 07:40
To: users@...
Subject: JSTL tags not working as expected.

Hi,

I think I have found out a bug, or an unexpected behaviour.

I have ported the the following code from a JSP view:

            <c:choose>
                <c:when test="${sessionScope.WW_TRANS_I18N_LOCALE=='en'}">
                    <cc:calendar id="calendar1" returnFunction="onENStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:when>
                <c:otherwise>
                    <cc:calendar id="calendar1" returnFunction="onFIStartDateSelected"
                        size="20" value="#{calendarSchedulingBean.startDate}" />
                </c:otherwise>
            </c:choose>


On the JSP there is no problem with the code, but with Facelets I get the "duplicate id"
error, because there are two instances of "calendar1".

The way I see it, the component tree should only have the component that was built,
depending on the "when" condition, but it seems both paths get processed.

Why does Facelets where work diferently than JSPs?

Thanks,
Paulo