You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Charbel Abdul-Massih <ca...@soundbite.com> on 2006/12/09 16:16:28 UTC
index properties and JSF
What's the best way to handle index properties in JSF...
I have a <c:foreach> loop inside of which I display a text input box
that can be edited...When I hit submit, how does JSF know which text
input box to map to which index of the array in the backing bean???
The JSF code goes like this:
<c:forEach items="#{bean.phones}" var="phone">
<h:inputText value="#{x.phoneValue}>
</c:forEach>
The backing bean has a member variable called phones of type ArrayList.
The ArrayList is an array of an internal object called Phone...
The question is when the phone values are edited on the screen and
submit is hit, how does JSF know which value to map to which index in
the backing bean array???
Thanks,
Charbel
Re: index properties and JSF
Posted by Hazem Saleh <ha...@gmail.com>.
u r welcome :-)
On 12/10/06, Simon Kitching <si...@rhe.co.nz> wrote:
> Hazem Saleh wrote:
> > Hi,
> > In JSF 1.2 you can easily make something like that by referring to the
> > current item using the EL.
> > See that example here :
> > http://www.jroller.com/page/HazemBlog?entry=my_first_glance_at_jsf
>
> Thanks for the info Hazem. I'm looking forward to JSP2.1 in Tomcat and
> JSF 1.2 in Myfaces...(if I haven't moved to Facelets by then :-).
>
> Regards,
>
> Simon
>
--
Hazem Ahmed Saleh Ahmed
IBM Egypt Cairo TDC ( Technology Development Center )
WebSphere Business Integration Modeler Software Engineer
http://www.jroller.com/page/HazemBlog
Re: index properties and JSF
Posted by Simon Kitching <si...@rhe.co.nz>.
Hazem Saleh wrote:
> Hi,
> In JSF 1.2 you can easily make something like that by referring to the
> current item using the EL.
> See that example here :
> http://www.jroller.com/page/HazemBlog?entry=my_first_glance_at_jsf
Thanks for the info Hazem. I'm looking forward to JSP2.1 in Tomcat and
JSF 1.2 in Myfaces...(if I haven't moved to Facelets by then :-).
Regards,
Simon
Re: index properties and JSF
Posted by Hazem Saleh <ha...@gmail.com>.
Hi,
In JSF 1.2 you can easily make something like that by referring to the
current item using the EL.
See that example here :
http://www.jroller.com/page/HazemBlog?entry=my_first_glance_at_jsf
Thanks
On 12/10/06, Simon Kitching <si...@rhe.co.nz> wrote:
> Charbel Abdul-Massih wrote:
> > What's the best way to handle index properties in JSF…
> >
> >
> >
> > I have a <c:foreach> loop inside of which I display a text input box
> > that can be edited…When I hit submit, how does JSF know which text input
> > box to map to which index of the array in the backing bean???
> >
> >
> >
> > The JSF code goes like this:
> >
> >
> >
> > <c:forEach items="#{bean.phones}" var="phone">
> >
> > <h:inputText value="#{x.phoneValue}>
> >
> > </c:forEach>
> >
> >
> >
> > The backing bean has a member variable called phones of type ArrayList.
> > The ArrayList is an array of an internal object called Phone…
> >
> > The question is when the phone values are edited on the screen and
> > submit is hit, how does JSF know which value to map to which index in
> > the backing bean array???
>
> The c:forEach and c:if statements do not integrate at all well with JSF
> (at least JSF 1.1; not sure about v1.2).
>
> Use a t:dataList instead. This component then provides a "var" variable
> that can be used to access "the component currently being processed".
>
> The t:dataList also provides a "rowIndexVar" variable that can be used
> to index into the "value" data list, though this is less elegant.
>
> http://myfaces.apache.org/tomahawk/tlddoc/t/dataList.html
>
> Regards,
>
> Simon
>
--
Hazem Ahmed Saleh Ahmed
IBM Egypt Cairo TDC ( Technology Development Center )
WebSphere Business Integration Modeler Software Engineer
http://www.jroller.com/page/HazemBlog
Re: index properties and JSF
Posted by Simon Kitching <si...@rhe.co.nz>.
Charbel Abdul-Massih wrote:
> What’s the best way to handle index properties in JSF…
>
>
>
> I have a <c:foreach> loop inside of which I display a text input box
> that can be edited…When I hit submit, how does JSF know which text input
> box to map to which index of the array in the backing bean???
>
>
>
> The JSF code goes like this:
>
>
>
> <c:forEach items="#{bean.phones}" var="phone">
>
> <h:inputText value=”#{x.phoneValue}>
>
> </c:forEach>
>
>
>
> The backing bean has a member variable called phones of type ArrayList.
> The ArrayList is an array of an internal object called Phone…
>
> The question is when the phone values are edited on the screen and
> submit is hit, how does JSF know which value to map to which index in
> the backing bean array???
The c:forEach and c:if statements do not integrate at all well with JSF
(at least JSF 1.1; not sure about v1.2).
Use a t:dataList instead. This component then provides a "var" variable
that can be used to access "the component currently being processed".
The t:dataList also provides a "rowIndexVar" variable that can be used
to index into the "value" data list, though this is less elegant.
http://myfaces.apache.org/tomahawk/tlddoc/t/dataList.html
Regards,
Simon