Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying N rows per page

 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all... I am using Struts and JSP for a project. I want to display a fixed no. of rows (retrieved from database) in a page. Can anyone please help me ? Its an urgency.

Thank u all in advance...
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nanda

I think you asking the same question second time , if you are using struts and jsp their are may ways to solve your proble,

If i am not wrong you might be getting a vector or arraylist of objects in your jsp and you want to display them in pages ,

you can use a additional taglibrary known as display taglib , if you want to use this you can search for tutorials on web ,or if decided tell i will sen you some example of this tag library,

their are many other options of doing the paging like using pager taglibrary or usting JSTL taglibrary their are many options

Best Regards
Pankaj
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pankaj....

I am extremely sorry if my question annoyed you. yes i m asking this question for 2nd time, but earlier i asked it in JSP room. Because i am using struts, hence i asked it again in this room. anyway, i have downloaded the displaytag but not getting those properly. kindly send some tutorial (with code if possible). thank you.
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nanada

--------------------------------------------------------------------------------
http://www.displaytag.org/example-paging.jsp

you can use this tutorial , this is the best example for displaytaglib

if any further problem comes you can post it here

Best Regards
Pankaj
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mr. Pankaj... thank you, but i have that tutorial earlier, but can't understand it properly. can you please explain the displaytag's functionality..

thank u in advance..
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nanda

ok lets go step by step

1: if you are using struts that mean all the logic is there in your action classes,

ok lets take an example where i will get the users which are deactivated in a discussion forum,

Wat i did in my action class is retrieved the data from datbases which has given me a arraylist of the user objects that contains abt 20 users and their details

now wat i did i have kept that in session scope

session.setAttribute("users",user);

now in my jsp i have to display five users in each page
so i wrote the following code to display that

<display:table name="sessionScope.user" pagesize="5">
<display:column property="id" title="ID" />
<display:column property="name" />
<display:column property="email" />
<display:column property="status" />
</display:table>

the properties id,name,email, status are the properties of the object stored in your arraylist that is you have class which actually has getter and setters for these properties.

I think this much is enough for you to complete the functionality

Best Regards
Pankaj
9818418298
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nanda

ok lets go step by step

1: if you are using struts that mean all the logic is there in your action classes,

ok lets take an example where i will get the users which are deactivated in a discussion forum,

Wat i did in my action class is retrieved the data from datbases which has given me a arraylist of the user objects that contains abt 20 users and their details

now wat i did i have kept that in session scope

session.setAttribute("users",user);

now in my jsp i have to display five users in each page
so i wrote the following code to display that

<display:table name="sessionScope.user" pagesize="5">
<display:column property="id" title="ID" />
<display:column property="name" />
<display:column property="email" />
<display:column property="status" />
</display:table>

the properties id,name,email, status are the properties of the object stored in your arraylist that is you have class which actually has getter and setters for these properties.

I think this much is enough for you to complete the functionality

Best Regards
Pankaj
9818418298
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mr. Pankaj.... I'll try it today and will let you know if i'll face anyproblem... and sir, along with that i'll ask you few questions on struts too. u can answer those if you have time.
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nanda

I wont have any problem in solving your questions if i know the answers,
and don't call me sir i am just 23 now and think may be equal to your age so it is good that you calll me pankaj


Best Regards
Pankaj
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello mr. pankaj... y'day i tried with that display tag. it is working fine. but can u tell me how to change the default layouts... means it has a common format like [First/Prev]....[Next/Last].. i want to replace these with pictures.
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nanda

the layout of this tag library cannot be changed if you want to change them you have to open the taglibrary and search for these words and try replacing them by your images

Best Regards
Pankaj
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Mr. Pankaj. Thank you for your earlier helps. Now I am asking something on another problem. I have a login form which is working fine. I am asking for 3 things on my login form (uid, passwd and utype). now if someone is rewiring the URL like "....?uid=nanda&passwd=nanda&utype=admin" then he can enter the administrator site. I want to restrict this. I mean how can I avaoid this URL hack ? Can you help me please.

Thank u in advance.
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI nanda

I think you have not given the method parameter in your jsp, just give method = post near your action tag in your jsp and the everything will vanish from your url

i mean
< form action ="/login" method = post>

Best Regards
Pankaj
 
Kiran Kumar
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Nanda,
you can write a Decorator class which extends the TableDecorator/Column Decorator to change the display format as you desire. do go through the documentation for the same.
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the default method in struts <html:form> tag is POST. and the Query string is not coming in the URL bar. however, using post method is also expensive. so i was thinking to use GET method rather. anyway, now i am thinking for another solution, Encrypted password. do u hav any idea on this ? how to send an encrypted password to the server and validate it after decrypting the password again.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ummm... POST expensive? I've never heard that before.

This topic is starting to slip into realms that might be better dealt with by one of the other forums at the ranch, as this is more of a general login authentication question.

Anyway, check out these links:
Different types of authentication

Basic tutorial for using Form-based auth

Hope they help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic