DisplayTag in request scope. How?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

DisplayTag in request scope. How?

JavaNoobie
online
33 posts
       
Hi All,
Im developing a web app that performs the display of data in a tabular manner.
Im trying to  use the display tag library  to help me with the pagination and sorting of the data being presented . But , seem to have hit a roadblock here , all samples of the displaytag library that I have come across , involve storing the entire resultset from the query in the session, which is a huge performance  issue for me , Does anybody know how I could use the displaytag library using only the request scope? Or any other library that helps in pagination but uses only the request??

Many Thanks,
Vivek.
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

Raaja G
Hi,

Set the object in request scope in your action class or servlet or other server side component in request scope. And get that collection object (object holding your data) from request scope. In name attribute give that object's name. No need to get the object from session.

--raaja. g
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

JavaNoobie
Hi raaja,
Thanks for replying
However I cant get it to work in request scope .
Can you please share a sample?
When I set it in request only the contents in the first page are displayed and when i click to view the next page the page returns empty.
Raaja G wrote
Hi,

Set the object in request scope in your action class or servlet or other server side component in request scope. And get that collection object (object holding your data) from request scope. In name attribute give that object's name. No need to get the object from session.

--raaja. g
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

Raaja G
Hi,

That will be because you might be giving wrong action in the requestURI. Just give the same action where you are setting the collection object in request scope. If you another action configuration then it will check for that action when you click next or previous.

Hope this will help you. Regarding example I am in to struts. And I am not aware of spring. which technology you are using for web development.

Thanks.

raaja g
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

JavaNoobie
Hi Raja,
Thanks for your reply. Can you please explain how I could manipulate the requestURI tag?
I'm currently not using any frameworks , just plain jsp , servlets and supporting java classes.
Raaja G wrote
Hi,

That will be because you might be giving wrong action in the requestURI. Just give the same action where you are setting the collection object in request scope. If you another action configuration then it will check for that action when you click next or previous.

Hope this will help you. Regarding example I am in to struts. And I am not aware of spring. which technology you are using for web development.

Thanks.

raaja g
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

Raaja G
Hi,

Then just give the action mentioned in the jsp form tag in the requestURI of display tag. In the calling servlet keep the collection object in request scope.

for ex:

if ur jsp is

<html><body>
<form action="someaction" method="post/get">
ur presentation code or jsp code

<display:table id="some name" name="your request scope object name" requestURI="/your action name in form tags action attribute" pagesize="10" cellpadding="2" cellspacing="2"> 
        <display:column property="getter method name" title="column title" sortable="true" style="text-align:center;" /> 
     
         </display:column> 
        <display:column title="Review" style="text-align:center;"> 
                       <html:multibox name="deptUsers" property="review" /> 
        </display:column> 
</display:table> 
</form>
</body>
</html>

in service or post or get method

List al = new ArrayList();
Bean b = new Bean();
b.set....(....);
al.add(b);

request.setAttribute("your request scope object name",al);
Reply | Threaded
Open this post in threaded view
|

Re: DisplayTag in request scope. How?

JavaNoobie
Hi Raaja,
I'm extremely sorry for the delay and thank you for the detailed response .So, according to what you say .
If I have a table in my jsp as below
<form name="test" action="TestServlet">
..
..

<display:table id="some name" name="MyTableContents" requestURI="TestServlet" pagesize="10" cellpadding="2" cellspacing="2"> 


</form>

and in the TestServlet, something like
List Contents=new Arraylist<>();
Bean B=new Bean();
Contents.add(B);
request.setAttribute("MyTableContents",Contents)
That is all I would need to do , right?
Once again , many thanks for helping out.
Regards.
Raaja G wrote
Hi,

Then just give the action mentioned in the jsp form tag in the requestURI of display tag. In the calling servlet keep the collection object in request scope.

for ex:

if ur jsp is

<html><body>
<form action="someaction" method="post/get">
ur presentation code or jsp code

<display:table id="some name" name="your request scope object name" requestURI="/your action name in form tags action attribute" pagesize="10" cellpadding="2" cellspacing="2"> 
        <display:column property="getter method name" title="column title" sortable="true" style="text-align:center;" /> 
     
         </display:column> 
        <display:column title="Review" style="text-align:center;"> 
                       <html:multibox name="deptUsers" property="review" /> 
        </display:column> 
</display:table> 
</form>
</body>
</html>

in service or post or get method

List al = new ArrayList();
Bean b = new Bean();
b.set....(....);
al.add(b);

request.setAttribute("your request scope object name",al);