Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Each row of a table as form

 
Dr Scott
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
-------------------------------------------------------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic