You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jorge Mascena <jo...@cesar.org.br> on 2003/03/24 18:37:35 UTC

Paging a collection property

I need some directions on how to use the struts html and/or neste
taglibs to handle the case where there's a collection property of a form
bean that may contain a big number of objects. In this case, I'd like to
able to do some sort of paging on these objects and I'd like to know if
struts have any support for that.

For example: I have a form bean, AuthorFormBean, that has a collection
of books he wrote. I can use the nested taglib to render the book
collection, so the user can fill the books data from the same form he
fills the rest of the data about the author. So far, so good.

The problem (or question) is: what if the number of books gets too big
and I want to split these books into pages (and have a navigator for
those pages), but they still belong to the same form bean, so no matter
which page the user is, the nested tags (<nested:text>, for example)
will know the correct index of the objects we're talking about (if we're
on page 2 and each page has 10 books, the nested tags will start getting
the objects from index 9 and not 0, and so on) and properly populates
the input fields and updates the corresponding objects when loading and
submiting the form respectively.

I know how to do it directly with pure html code, but I'd like to know
if it would be possible to get some advantage on using struts for this
matter.

I hope I could make myself clear.

Thanks for any help.

Jorge Mascena


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RES: RES: Paging a collection property

Posted by Jorge Mascena <jo...@cesar.org.br>.
I figured it out. I was missing that you can iterate just a portion of a
collection with nested:iterate (i.e., you can specify offset and
length). This was the missing link.

Thanks anyway.

J

> -----Mensagem original-----
> De: Vic Cekvenich [mailto:vc@basebeans.com] 
> Enviada em: Monday, March 24, 2003 4:34 PM
> Para: struts-user@jakarta.apache.org
> Assunto: Re: RES: Paging a collection property
> 
> 
> Struts is very smart about multi row update (and tag uses 
> indexed tag). But I have no idea how YOUR tag works, as far 
> is iterator, is per page 
> or over the collection.
> 
> .V
> 
> 
> 
> Jorge Mascena wrote:
> > Sorry if I didn't explain the problem better. The 
> pagination itself is 
> > ok (I've built a taglib that's equivalent to the one you 
> pointed me).
> > 
> > My question is how I can bind the input fields generated by 
> the html 
> > and/or nested tags to the underlying objects so that any change the 
> > user makes to the input fields will be reflected on the 
> properties of 
> > the corresponding books (to use the same example from the original 
> > message).
> > 
> > Say the user is on page 2 and each page has 10 books. He 
> changes the 
> > title of the first book of the page and submits the form. I want to 
> > know if struts will be "smart" enough to update the title 
> of the 11th 
> > book and not the 1st book of the collection of books of the 
> author. If 
> > so, what do I have to do to accomplish that?
> > 
> > Thanks
> > 
> > Jorge Mascena
> > 
> > 
> >>-----Mensagem original-----
> >>De: Vic Cekvenich [mailto:vc@basebeans.com]
> >>Enviada em: Monday, March 24, 2003 3:22 PM
> >>Para: struts-user@jakarta.apache.org
> >>Assunto: Re: Paging a collection property
> >>
> >>
> >>Look at "display tag" in google.
> >>hth, .V
> >>
> >>Jorge Mascena wrote:
> >>
> >>>I need some directions on how to use the struts html and/or neste
> >>>taglibs to handle the case where there's a collection 
> property of a 
> >>>form bean that may contain a big number of objects. In this 
> >>
> >>case, I'd
> >>
> >>>like to able to do some sort of paging on these objects and
> >>
> >>I'd like
> >>
> >>>to know if struts have any support for that.
> >>>
> >>>For example: I have a form bean, AuthorFormBean, that has a
> >>
> >>collection
> >>
> >>>of books he wrote. I can use the nested taglib to render the book
> >>>collection, so the user can fill the books data from the 
> >>
> >>same form he
> >>
> >>>fills the rest of the data about the author. So far, so good.
> >>>
> >>>The problem (or question) is: what if the number of books
> >>
> >>gets too big
> >>
> >>>and I want to split these books into pages (and have a
> >>
> >>navigator for
> >>
> >>>those pages), but they still belong to the same form bean, so no
> >>>matter which page the user is, the nested tags (<nested:text>, for 
> >>>example) will know the correct index of the objects we're talking 
> >>>about (if we're on page 2 and each page has 10 books, the 
> >>
> >>nested tags
> >>
> >>>will start getting the objects from index 9 and not 0, and
> >>
> >>so on) and
> >>
> >>>properly populates the input fields and updates the corresponding
> >>>objects when loading and submiting the form respectively.
> >>>
> >>>I know how to do it directly with pure html code, but I'd
> >>
> >>like to know
> >>
> >>>if it would be possible to get some advantage on using
> >>
> >>struts for this
> >>
> >>>matter.
> >>>
> >>>I hope I could make myself clear.
> >>>
> >>>Thanks for any help.
> >>>
> >>>Jorge Mascena
> >>
> >>
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: RES: Paging a collection property

Posted by Vic Cekvenich <vc...@basebeans.com>.
Struts is very smart about multi row update (and tag uses indexed tag).
But I have no idea how YOUR tag works, as far is iterator, is per page 
or over the collection.

.V



Jorge Mascena wrote:
> Sorry if I didn't explain the problem better. The pagination itself is
> ok (I've built a taglib that's equivalent to the one you pointed me).
> 
> My question is how I can bind the input fields generated by the html
> and/or nested tags to the underlying objects so that any change the user
> makes to the input fields will be reflected on the properties of the
> corresponding books (to use the same example from the original message).
> 
> Say the user is on page 2 and each page has 10 books. He changes the
> title of the first book of the page and submits the form. I want to know
> if struts will be "smart" enough to update the title of the 11th book
> and not the 1st book of the collection of books of the author. If so,
> what do I have to do to accomplish that?
> 
> Thanks
> 
> Jorge Mascena
> 
> 
>>-----Mensagem original-----
>>De: Vic Cekvenich [mailto:vc@basebeans.com] 
>>Enviada em: Monday, March 24, 2003 3:22 PM
>>Para: struts-user@jakarta.apache.org
>>Assunto: Re: Paging a collection property
>>
>>
>>Look at "display tag" in google.
>>hth, .V
>>
>>Jorge Mascena wrote:
>>
>>>I need some directions on how to use the struts html and/or neste 
>>>taglibs to handle the case where there's a collection property of a 
>>>form bean that may contain a big number of objects. In this 
>>
>>case, I'd 
>>
>>>like to able to do some sort of paging on these objects and 
>>
>>I'd like 
>>
>>>to know if struts have any support for that.
>>>
>>>For example: I have a form bean, AuthorFormBean, that has a 
>>
>>collection 
>>
>>>of books he wrote. I can use the nested taglib to render the book 
>>>collection, so the user can fill the books data from the 
>>
>>same form he 
>>
>>>fills the rest of the data about the author. So far, so good.
>>>
>>>The problem (or question) is: what if the number of books 
>>
>>gets too big 
>>
>>>and I want to split these books into pages (and have a 
>>
>>navigator for 
>>
>>>those pages), but they still belong to the same form bean, so no 
>>>matter which page the user is, the nested tags (<nested:text>, for 
>>>example) will know the correct index of the objects we're talking 
>>>about (if we're on page 2 and each page has 10 books, the 
>>
>>nested tags 
>>
>>>will start getting the objects from index 9 and not 0, and 
>>
>>so on) and 
>>
>>>properly populates the input fields and updates the corresponding 
>>>objects when loading and submiting the form respectively.
>>>
>>>I know how to do it directly with pure html code, but I'd 
>>
>>like to know 
>>
>>>if it would be possible to get some advantage on using 
>>
>>struts for this 
>>
>>>matter.
>>>
>>>I hope I could make myself clear.
>>>
>>>Thanks for any help.
>>>
>>>Jorge Mascena
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RES: Paging a collection property

Posted by Jorge Mascena <jo...@cesar.org.br>.
Sorry if I didn't explain the problem better. The pagination itself is
ok (I've built a taglib that's equivalent to the one you pointed me).

My question is how I can bind the input fields generated by the html
and/or nested tags to the underlying objects so that any change the user
makes to the input fields will be reflected on the properties of the
corresponding books (to use the same example from the original message).

Say the user is on page 2 and each page has 10 books. He changes the
title of the first book of the page and submits the form. I want to know
if struts will be "smart" enough to update the title of the 11th book
and not the 1st book of the collection of books of the author. If so,
what do I have to do to accomplish that?

Thanks

Jorge Mascena

> -----Mensagem original-----
> De: Vic Cekvenich [mailto:vc@basebeans.com] 
> Enviada em: Monday, March 24, 2003 3:22 PM
> Para: struts-user@jakarta.apache.org
> Assunto: Re: Paging a collection property
> 
> 
> Look at "display tag" in google.
> hth, .V
> 
> Jorge Mascena wrote:
> > I need some directions on how to use the struts html and/or neste 
> > taglibs to handle the case where there's a collection property of a 
> > form bean that may contain a big number of objects. In this 
> case, I'd 
> > like to able to do some sort of paging on these objects and 
> I'd like 
> > to know if struts have any support for that.
> > 
> > For example: I have a form bean, AuthorFormBean, that has a 
> collection 
> > of books he wrote. I can use the nested taglib to render the book 
> > collection, so the user can fill the books data from the 
> same form he 
> > fills the rest of the data about the author. So far, so good.
> > 
> > The problem (or question) is: what if the number of books 
> gets too big 
> > and I want to split these books into pages (and have a 
> navigator for 
> > those pages), but they still belong to the same form bean, so no 
> > matter which page the user is, the nested tags (<nested:text>, for 
> > example) will know the correct index of the objects we're talking 
> > about (if we're on page 2 and each page has 10 books, the 
> nested tags 
> > will start getting the objects from index 9 and not 0, and 
> so on) and 
> > properly populates the input fields and updates the corresponding 
> > objects when loading and submiting the form respectively.
> > 
> > I know how to do it directly with pure html code, but I'd 
> like to know 
> > if it would be possible to get some advantage on using 
> struts for this 
> > matter.
> > 
> > I hope I could make myself clear.
> > 
> > Thanks for any help.
> > 
> > Jorge Mascena
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Paging a collection property

Posted by Vic Cekvenich <vc...@basebeans.com>.
Look at "display tag" in google.
hth, .V

Jorge Mascena wrote:
> I need some directions on how to use the struts html and/or neste
> taglibs to handle the case where there's a collection property of a form
> bean that may contain a big number of objects. In this case, I'd like to
> able to do some sort of paging on these objects and I'd like to know if
> struts have any support for that.
> 
> For example: I have a form bean, AuthorFormBean, that has a collection
> of books he wrote. I can use the nested taglib to render the book
> collection, so the user can fill the books data from the same form he
> fills the rest of the data about the author. So far, so good.
> 
> The problem (or question) is: what if the number of books gets too big
> and I want to split these books into pages (and have a navigator for
> those pages), but they still belong to the same form bean, so no matter
> which page the user is, the nested tags (<nested:text>, for example)
> will know the correct index of the objects we're talking about (if we're
> on page 2 and each page has 10 books, the nested tags will start getting
> the objects from index 9 and not 0, and so on) and properly populates
> the input fields and updates the corresponding objects when loading and
> submiting the form respectively.
> 
> I know how to do it directly with pure html code, but I'd like to know
> if it would be possible to get some advantage on using struts for this
> matter.
> 
> I hope I could make myself clear.
> 
> Thanks for any help.
> 
> Jorge Mascena



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org