You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Anders W. Tell" <an...@websoft.fi> on 2006/06/21 17:05:27 UTC

Looping in JSF?

Hi,

I want to create list of commandButtons based on a collection of 
ActionObjects. so I want to loop over my collection of this.
But I cant seem to find looping constructs in JSF except from the DataTable.

Does <c:forEach> work or how do I mix it with Java constructs in a JSP file

thanks for any hints
/anders



Re: Looping in JSF?

Posted by "Anders W. Tell" <an...@websoft.fi>.
Hi,

Youre probably right. I fixed it in another way where I skipped the 
attribute and hooked in the actionExecutionListener() to the Action 
object and kept the wizard.actionExecution()

thanks anyway for your kind help!
/anders

Bruno Aranda wrote:
> Maybe this is due to the fact that you have a java attribute names not
> following the convetions ("ID"), that can provoke problems when using
> reflection. Can you try to use this and see what happens?
>
> <f:attribute name="actionID" value="#{action.iD}"/> (note the i of iD
> is lower case)
>
> To see if this is what is happening, try to rename the attribute ID
> from your Action class to "id" or "identifier", and try "#{action.id}"
> or "#{action.identifier}.
>
> Hope that helps!
>
> Bruno
>
> On 6/22/06, Anders W. Tell <an...@websoft.fi> wrote:
>> Hi,
>>
>> Thanks for the help. Found a followup problem, for some reasons the
>> attributes don't get propagated, below lAID is null in
>> actionExecutionListener?!
>>
>>         Map lAParams = event.getComponent().getAttributes();
>>         Object lAID =lAParams.get("actionID");
>>
>>
>> <t:dataList var="action" value="#{wizard.actions}" layout="simple">
>>  <h:commandButton value="#{action.label}"
>> actionListener="#{wizard.actionExecutionListener}"
>> action="#{wizard.actionExecution}">
>>    <f:attribute name="actionID" value="#{action.ID}"/>
>> </h:commandButton>
>> </t:dataList>
>>
>> regards
>> /anders
>>
>> Bruno Aranda wrote:
>> > Hi, have you tried the t:dataList [1] component in tomahawk? I guess
>> > it does what you need...
>> >
>> > Regards,
>> >
>> > Bruno
>> >
>> > [1] http://myfaces.apache.org/tomahawk/dataList.html
>> >
>> > On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
>> >> Hi,
>> >>
>> >> I want to create list of commandButtons based on a collection of
>> >> ActionObjects. so I want to loop over my collection of this.
>> >> But I cant seem to find looping constructs in JSF except from the
>> >> DataTable.
>> >>
>> >> Does <c:forEach> work or how do I mix it with Java constructs in a
>> >> JSP file
>> >>
>> >> thanks for any hints
>> >> /anders
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>


Re: Looping in JSF?

Posted by Bruno Aranda <br...@gmail.com>.
Maybe this is due to the fact that you have a java attribute names not
following the convetions ("ID"), that can provoke problems when using
reflection. Can you try to use this and see what happens?

<f:attribute name="actionID" value="#{action.iD}"/> (note the i of iD
is lower case)

To see if this is what is happening, try to rename the attribute ID
from your Action class to "id" or "identifier", and try "#{action.id}"
or "#{action.identifier}.

Hope that helps!

Bruno

On 6/22/06, Anders W. Tell <an...@websoft.fi> wrote:
> Hi,
>
> Thanks for the help. Found a followup problem, for some reasons the
> attributes don't get propagated, below lAID is null in
> actionExecutionListener?!
>
>         Map lAParams = event.getComponent().getAttributes();
>         Object lAID =lAParams.get("actionID");
>
>
> <t:dataList var="action" value="#{wizard.actions}" layout="simple">
>  <h:commandButton value="#{action.label}"
> actionListener="#{wizard.actionExecutionListener}"
> action="#{wizard.actionExecution}">
>    <f:attribute name="actionID" value="#{action.ID}"/>
> </h:commandButton>
> </t:dataList>
>
> regards
> /anders
>
> Bruno Aranda wrote:
> > Hi, have you tried the t:dataList [1] component in tomahawk? I guess
> > it does what you need...
> >
> > Regards,
> >
> > Bruno
> >
> > [1] http://myfaces.apache.org/tomahawk/dataList.html
> >
> > On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
> >> Hi,
> >>
> >> I want to create list of commandButtons based on a collection of
> >> ActionObjects. so I want to loop over my collection of this.
> >> But I cant seem to find looping constructs in JSF except from the
> >> DataTable.
> >>
> >> Does <c:forEach> work or how do I mix it with Java constructs in a
> >> JSP file
> >>
> >> thanks for any hints
> >> /anders
> >>
> >>
> >>
> >
> >
>
>

Re: Looping in JSF?

Posted by "Anders W. Tell" <an...@websoft.fi>.
Hi,

Thanks for the help. Found a followup problem, for some reasons the 
attributes don't get propagated, below lAID is null in 
actionExecutionListener?!

        Map lAParams = event.getComponent().getAttributes();
        Object lAID =lAParams.get("actionID");


<t:dataList var="action" value="#{wizard.actions}" layout="simple">
 <h:commandButton value="#{action.label}" 
actionListener="#{wizard.actionExecutionListener}" 
action="#{wizard.actionExecution}">
   <f:attribute name="actionID" value="#{action.ID}"/>
</h:commandButton>
</t:dataList>

regards
/anders

Bruno Aranda wrote:
> Hi, have you tried the t:dataList [1] component in tomahawk? I guess
> it does what you need...
>
> Regards,
>
> Bruno
>
> [1] http://myfaces.apache.org/tomahawk/dataList.html
>
> On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
>> Hi,
>>
>> I want to create list of commandButtons based on a collection of
>> ActionObjects. so I want to loop over my collection of this.
>> But I cant seem to find looping constructs in JSF except from the 
>> DataTable.
>>
>> Does <c:forEach> work or how do I mix it with Java constructs in a 
>> JSP file
>>
>> thanks for any hints
>> /anders
>>
>>
>>
>
>


Re: Looping in JSF?

Posted by Andrew Robinson <an...@gmail.com>.
data list should be your friend. With layout=simple there are no HTML
tags added, only the contents of the list. It has index and max count
properties as well that make it easy to work with.

On 6/21/06, ::SammyRulez:: <sa...@gmail.com> wrote:
> using facelets you can use also c:foreach but I think that you can do
> everithing also with t:datatable
>
> 2006/6/21, Bruno Aranda <br...@gmail.com>:
> > Hi, have you tried the t:dataList [1] component in tomahawk? I guess
> > it does what you need...
> >
> > Regards,
> >
> > Bruno
> >
> > [1] http://myfaces.apache.org/tomahawk/dataList.html
> >
> > On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
> > > Hi,
> > >
> > > I want to create list of commandButtons based on a collection of
> > > ActionObjects. so I want to loop over my collection of this.
> > > But I cant seem to find looping constructs in JSF except from the DataTable.
> > >
> > > Does <c:forEach> work or how do I mix it with Java constructs in a JSP file
> > >
> > > thanks for any hints
> > > /anders
> > >
> > >
> > >
> >
>
>
> --
> ::SammyRulez::
> http://www.kyub.com/blojsom/
> Un hacker è una "persona che si impegna nell'affrontare sfide
> intellettuali per aggirare o superare creativamente le limitazioni che
> gli vengono imposte, non limitatamente ai suoi ambiti d'interesse, ma
> in tutti gli aspetti della sua vita"
>

Re: Looping in JSF?

Posted by "::SammyRulez::" <sa...@gmail.com>.
using facelets you can use also c:foreach but I think that you can do
everithing also with t:datatable

2006/6/21, Bruno Aranda <br...@gmail.com>:
> Hi, have you tried the t:dataList [1] component in tomahawk? I guess
> it does what you need...
>
> Regards,
>
> Bruno
>
> [1] http://myfaces.apache.org/tomahawk/dataList.html
>
> On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
> > Hi,
> >
> > I want to create list of commandButtons based on a collection of
> > ActionObjects. so I want to loop over my collection of this.
> > But I cant seem to find looping constructs in JSF except from the DataTable.
> >
> > Does <c:forEach> work or how do I mix it with Java constructs in a JSP file
> >
> > thanks for any hints
> > /anders
> >
> >
> >
>


-- 
::SammyRulez::
http://www.kyub.com/blojsom/
Un hacker è una "persona che si impegna nell'affrontare sfide
intellettuali per aggirare o superare creativamente le limitazioni che
gli vengono imposte, non limitatamente ai suoi ambiti d'interesse, ma
in tutti gli aspetti della sua vita"

Re: Looping in JSF?

Posted by Bruno Aranda <br...@gmail.com>.
Hi, have you tried the t:dataList [1] component in tomahawk? I guess
it does what you need...

Regards,

Bruno

[1] http://myfaces.apache.org/tomahawk/dataList.html

On 6/21/06, Anders W. Tell <an...@websoft.fi> wrote:
> Hi,
>
> I want to create list of commandButtons based on a collection of
> ActionObjects. so I want to loop over my collection of this.
> But I cant seem to find looping constructs in JSF except from the DataTable.
>
> Does <c:forEach> work or how do I mix it with Java constructs in a JSP file
>
> thanks for any hints
> /anders
>
>
>

RE: Looping in JSF?

Posted by Julian Ray <ju...@yahoo.com>.
I'm no expert on EL but what you are describing sounds like a good candidate
for a custom component.

-----Original Message-----
From: Anders W. Tell [mailto:anders.w.tell@websoft.fi] 
Sent: Wednesday, June 21, 2006 11:05 AM
To: MyFaces Discussion
Subject: Looping in JSF?

Hi,

I want to create list of commandButtons based on a collection of
ActionObjects. so I want to loop over my collection of this.
But I cant seem to find looping constructs in JSF except from the DataTable.

Does <c:forEach> work or how do I mix it with Java constructs in a JSP file

thanks for any hints
/anders