You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by robin bajaj <ro...@gmail.com> on 2007/04/08 17:48:18 UTC

[OT] problem with displaytag column sorting in struts 1.2 web project

Hi All,
In my Struts 1.2.x webapp, I am getting some Patient records from 
backend using my PatientManager businessObject (which uses Hibernate)
to send back a populated Patients List in the request scope. (Patient is 
my bean).

I am feeding this patientsList to Displaytag table,
to show the data in a table.

Here's the code snippet for my jsp containing displaytag table.
http://rafb.net/p/artIJr98.html

Now, I want to sort this table based on the PatientID
when I click on the PatientID column.

I read in the Displaytag docs

http://displaytag.homeip.net/displaytag-examples-1.1/example-sorting.jsp

where it mentions the following :

If you want to allow the user to sort the data as it is coming back, 
then you need to just do two things, make sure that the data returned 
from your property implements the Comparable interface (if it doesn't 
natively - use the decorator pattern as shown a couple of examples ago), 
and then set the attribute sortable="true" on the columns that you want 
to be able to sort by.


Following the above suggestion, I changed my Patient class to implement 
Comparable interface and implemented the following compareTo method (as 
following)
http://rafb.net/p/t0CR4Q98.html

Then I re-build my app and restart it on the server, the displaytag 
table shows up fine. But when I click on the first column PtId, it 
doesn't sort the table. I just get the Http404 error page.

Am I missing something ?

Please help,
thanks in advance,
robin.

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


Re: [OT] problem with displaytag column sorting in struts 1.2 web project

Posted by robinbajaj <ro...@gmail.com>.
Awesome, worked like a charm. Thanks a ton !


Tim Williams wrote:
> 
> Just put requestURI="/mypage.do"  (where mypage.do==the page that
> displays the table).
> 
> --tim
> 
> On 4/8/07, robinbajaj <ro...@gmail.com> wrote:
>>
>> thanks for the tip.
>> can you please provide more specific example/code-snippet for using the
>> requestURI attribute. i couldnt find enough documentation on this
>> feature.
>> thanks in advance,
>> robin
>>
>>
>> Tim Williams wrote:
>> >
>> > On 4/8/07, robin bajaj <ro...@gmail.com> wrote:
>> >> Hi All,
>> >> In my Struts 1.2.x webapp, I am getting some Patient records from
>> >> backend using my PatientManager businessObject (which uses Hibernate)
>> >> to send back a populated Patients List in the request scope. (Patient
>> is
>> >> my bean).
>> >>
>> >> I am feeding this patientsList to Displaytag table,
>> >> to show the data in a table.
>> >>
>> >> Here's the code snippet for my jsp containing displaytag table.
>> >> http://rafb.net/p/artIJr98.html
>> >>
>> >> Now, I want to sort this table based on the PatientID
>> >> when I click on the PatientID column.
>> >>
>> >> I read in the Displaytag docs
>> >>
>> >>
>> http://displaytag.homeip.net/displaytag-examples-1.1/example-sorting.jsp
>> >>
>> >> where it mentions the following :
>> >>
>> >> If you want to allow the user to sort the data as it is coming back,
>> >> then you need to just do two things, make sure that the data returned
>> >> from your property implements the Comparable interface (if it doesn't
>> >> natively - use the decorator pattern as shown a couple of examples
>> ago),
>> >> and then set the attribute sortable="true" on the columns that you
>> want
>> >> to be able to sort by.
>> >>
>> >>
>> >> Following the above suggestion, I changed my Patient class to
>> implement
>> >> Comparable interface and implemented the following compareTo method
>> (as
>> >> following)
>> >> http://rafb.net/p/t0CR4Q98.html
>> >>
>> >> Then I re-build my app and restart it on the server, the displaytag
>> >> table shows up fine. But when I click on the first column PtId, it
>> >> doesn't sort the table. I just get the Http404 error page.
>> >>
>> >> Am I missing something ?
>> >
>> > Try setting the requestURI attribute of the table itself?
>> > --tim
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-OT--problem-with-displaytag-column-sorting-in-struts-1.2-web-project-tf3543922.html#a9895137
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-OT--problem-with-displaytag-column-sorting-in-struts-1.2-web-project-tf3543922.html#a9908623
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [OT] problem with displaytag column sorting in struts 1.2 web project

Posted by Tim Williams <wi...@gmail.com>.
Just put requestURI="/mypage.do"  (where mypage.do==the page that
displays the table).

--tim

On 4/8/07, robinbajaj <ro...@gmail.com> wrote:
>
> thanks for the tip.
> can you please provide more specific example/code-snippet for using the
> requestURI attribute. i couldnt find enough documentation on this feature.
> thanks in advance,
> robin
>
>
> Tim Williams wrote:
> >
> > On 4/8/07, robin bajaj <ro...@gmail.com> wrote:
> >> Hi All,
> >> In my Struts 1.2.x webapp, I am getting some Patient records from
> >> backend using my PatientManager businessObject (which uses Hibernate)
> >> to send back a populated Patients List in the request scope. (Patient is
> >> my bean).
> >>
> >> I am feeding this patientsList to Displaytag table,
> >> to show the data in a table.
> >>
> >> Here's the code snippet for my jsp containing displaytag table.
> >> http://rafb.net/p/artIJr98.html
> >>
> >> Now, I want to sort this table based on the PatientID
> >> when I click on the PatientID column.
> >>
> >> I read in the Displaytag docs
> >>
> >> http://displaytag.homeip.net/displaytag-examples-1.1/example-sorting.jsp
> >>
> >> where it mentions the following :
> >>
> >> If you want to allow the user to sort the data as it is coming back,
> >> then you need to just do two things, make sure that the data returned
> >> from your property implements the Comparable interface (if it doesn't
> >> natively - use the decorator pattern as shown a couple of examples ago),
> >> and then set the attribute sortable="true" on the columns that you want
> >> to be able to sort by.
> >>
> >>
> >> Following the above suggestion, I changed my Patient class to implement
> >> Comparable interface and implemented the following compareTo method (as
> >> following)
> >> http://rafb.net/p/t0CR4Q98.html
> >>
> >> Then I re-build my app and restart it on the server, the displaytag
> >> table shows up fine. But when I click on the first column PtId, it
> >> doesn't sort the table. I just get the Http404 error page.
> >>
> >> Am I missing something ?
> >
> > Try setting the requestURI attribute of the table itself?
> > --tim
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/-OT--problem-with-displaytag-column-sorting-in-struts-1.2-web-project-tf3543922.html#a9895137
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [OT] problem with displaytag column sorting in struts 1.2 web project

Posted by robinbajaj <ro...@gmail.com>.
thanks for the tip.
can you please provide more specific example/code-snippet for using the 
requestURI attribute. i couldnt find enough documentation on this feature. 
thanks in advance, 
robin


Tim Williams wrote:
> 
> On 4/8/07, robin bajaj <ro...@gmail.com> wrote:
>> Hi All,
>> In my Struts 1.2.x webapp, I am getting some Patient records from
>> backend using my PatientManager businessObject (which uses Hibernate)
>> to send back a populated Patients List in the request scope. (Patient is
>> my bean).
>>
>> I am feeding this patientsList to Displaytag table,
>> to show the data in a table.
>>
>> Here's the code snippet for my jsp containing displaytag table.
>> http://rafb.net/p/artIJr98.html
>>
>> Now, I want to sort this table based on the PatientID
>> when I click on the PatientID column.
>>
>> I read in the Displaytag docs
>>
>> http://displaytag.homeip.net/displaytag-examples-1.1/example-sorting.jsp
>>
>> where it mentions the following :
>>
>> If you want to allow the user to sort the data as it is coming back,
>> then you need to just do two things, make sure that the data returned
>> from your property implements the Comparable interface (if it doesn't
>> natively - use the decorator pattern as shown a couple of examples ago),
>> and then set the attribute sortable="true" on the columns that you want
>> to be able to sort by.
>>
>>
>> Following the above suggestion, I changed my Patient class to implement
>> Comparable interface and implemented the following compareTo method (as
>> following)
>> http://rafb.net/p/t0CR4Q98.html
>>
>> Then I re-build my app and restart it on the server, the displaytag
>> table shows up fine. But when I click on the first column PtId, it
>> doesn't sort the table. I just get the Http404 error page.
>>
>> Am I missing something ?
> 
> Try setting the requestURI attribute of the table itself?
> --tim
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-OT--problem-with-displaytag-column-sorting-in-struts-1.2-web-project-tf3543922.html#a9895137
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [OT] problem with displaytag column sorting in struts 1.2 web project

Posted by Tim Williams <wi...@gmail.com>.
On 4/8/07, robin bajaj <ro...@gmail.com> wrote:
> Hi All,
> In my Struts 1.2.x webapp, I am getting some Patient records from
> backend using my PatientManager businessObject (which uses Hibernate)
> to send back a populated Patients List in the request scope. (Patient is
> my bean).
>
> I am feeding this patientsList to Displaytag table,
> to show the data in a table.
>
> Here's the code snippet for my jsp containing displaytag table.
> http://rafb.net/p/artIJr98.html
>
> Now, I want to sort this table based on the PatientID
> when I click on the PatientID column.
>
> I read in the Displaytag docs
>
> http://displaytag.homeip.net/displaytag-examples-1.1/example-sorting.jsp
>
> where it mentions the following :
>
> If you want to allow the user to sort the data as it is coming back,
> then you need to just do two things, make sure that the data returned
> from your property implements the Comparable interface (if it doesn't
> natively - use the decorator pattern as shown a couple of examples ago),
> and then set the attribute sortable="true" on the columns that you want
> to be able to sort by.
>
>
> Following the above suggestion, I changed my Patient class to implement
> Comparable interface and implemented the following compareTo method (as
> following)
> http://rafb.net/p/t0CR4Q98.html
>
> Then I re-build my app and restart it on the server, the displaytag
> table shows up fine. But when I click on the first column PtId, it
> doesn't sort the table. I just get the Http404 error page.
>
> Am I missing something ?

Try setting the requestURI attribute of the table itself?
--tim

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