jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Help with a gui requirement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help with a gui requirement" Watch "Help with a gui requirement" New topic
Author

Help with a gui requirement

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I have a search screen that populates multiple records on the same page as the search screen. There are two ways a user can navigate to get detail information pertaining to each record.

1. Double clicking the row.

2. highlighting the row and then clicking a "Get Detail" button present at the end of the screen.

Can anyone guide me of how this can be acheieved. Right now I display the search results as a table. I am not sure how I can highlight or allow user to click the record and show a detailed page.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
the <tr> HTML element supports both an onclick an an ondblclick event. You can use these two events to accomplish what you want. You can write JavaScript attached to the onclick event to change the style of the row so that it has a darker background color and looks like it's highlighted. You can also determine which row was clicked by using the rowIndex property (this.rowIndex). Once you have that you can populate a hidded field that will tell which row's information to retrieve when the form is submitted.

When the ondblclick event occurs, you can populate a hidden field with the selected row, and then submit the form.

Since all of this has to be done in JavaScript, you've obviously got to have a bit of JavaScript skill. If you don't have that skill now, you're going to have to spend some time with tutorials and reference materials to get up to speed on JavaScript before you can write this.
[ February 21, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
You can try doing this way,



Define a javascript function called functionview and hit the action class to get details.

Hope this helps.

Thanks and Regards,
Arul.
shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
thanks for all your help. I am able to click on a row and open a detail screen(for now it is a welcome screen).

I need to transfer an Object(contains detailed info of the record) chosen to this page. The object has all the deatil information. How to proceed?

appreciate your reply.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In my opinion, trying to transfer the entire object from one JSP to another is not the best approach. The whole point of having a detail page is to display more information than you have on the "list" page. I'd suggest you just re-get the information from the database. That way you only have to pass the key, rather than an entire set of information.

For example, suppose your list is a list of customers, each of which has a customer ID. Just create an action called DisplayCustomerDetails that looks for a "customerId" parameter, gets the information from the database, and forwards to a JSP. Then when the user clicks the row, just pass the following URI:
shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
thnx
shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I am able to retrieve detail info by clicking the hyperlink. But I am unable to do so by cliking on the whole record itself. How do I retrieve the GroupId value based on the row highlighted. Is hidden field the only solution?
[ February 22, 2007: Message edited by: shah rah ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One solution would be to have server-side code insert the Group ID into the JavaScript code. Example:


[ February 22, 2007: Message edited by: Merrill Higginson ]
[ February 22, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with a gui requirement
 
Similar Threads
Need to display results from the Database with hyperlink functionality
Using a Dynamic Table on My JSP
JSF collection datatable editing
pass parameter inside action path in struts-config.xml
no RadioButtonCell in GWT 2.4 Cell?