wood burning stoves 2.0*
The moose likes Struts and the fly likes Each row of a table as form 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 "Each row of a table as form" Watch "Each row of a table as form" New topic
Author

Each row of a table as form

Dr Scott
Greenhorn

Joined: Jul 20, 2011
Posts: 2
Hi,

i am using <display:table ...... > tag to generate table data at run time.

each row in generated table has a link "post" in one cell.

below is rough table figure .

Sl No ------------ Action

1 --------------------- post

2 --------------------- post


below is the code to display the table:


<display:table name="loadQueriesApprovedList" class="its" id="loadMyQueryData">
<display:caption>Queries Approved</display:caption>
<s:form action="" method="POST">
<display:column property="slNo" title="Sl No" />
<display:column property="date_replied" title="Date replied" />
<display:column property="issue_summary" title="Issue Summary" maxLength="30"/>
<display:column property="response" title="Response" maxLength="30" />
<display:column property="link" title="Link on SDF" />
<display:column value="POST" href="/AppUpdatePortal/CQnA/PostQuery.action" title="ACTION" />

</s:form>
</display:table>

on click of link "post" its calling PostQuery action.
i want "Sl No" of the corresponding row in action calss.

Could you please tell me how to do that.

Thanks,
Scott

Komal Renu
Ranch Hand

Joined: Jul 21, 2011
Posts: 51
Hi Scott,

Instead of the last line, you can do the following inside the display Column tag:

<display:column title="ACTION">
<a href="#" onclick="javascript:submitFormDetails('<bean:write name="loadMyQueryData" property="slNo"/>');">Post</a>
</display:column>

By this way, you can get the slNo in the javascript function 'submitFormDetails', which you can assign to a form property and extract in the Action class.

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
Dr Scott
Greenhorn

Joined: Jul 20, 2011
Posts: 2
Hi Komal,

Thanks for the reply.
But i am not able pass '<bean:write name="loadMyQueryData" property="slNo"/>' as parameter.
It closing the anchor tag at property="slNo"/> and hence creating page error.
Can you tell me how to do this.
and how to set bean property to form in javascript function.

Thanks.
Komal Renu
Ranch Hand

Joined: Jul 21, 2011
Posts: 51
Hi Scott,

I've tried the same thing for <a href.... > in my project and it works as expected. Possibly there might be some other issue in your JSP which is causing the page error.

About setting the bean property in form, firstly define a property in form, say for eg: selectedSlNo. Now on the jsp give a hidden property for this.
the javascript function would be something like

function submitFormDetails(slNo){
document.getElementById(selectedSlNo).value = slNo;
// other operations if any and then form submit
}

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Each row of a table as form
 
Similar Threads
Display Tag Issue JSP
Struts2 + display tag
s:radio and display tag
How to pass multiple parameters. Displaytag row value not changing on dynamic link
Struts Dojo Tree disappears on page reload