Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  67] [ 6]  / answers: 1 / hits: 18529  / 13 Years ago, wed, december 14, 2011, 12:00:00

I am using display tag to display data in a table on a JSP. Now I want to give two links for each row, one for editing & one for deleting the row.



There are some posts on stackoverflow regarding the same([question]: How to use multiple buttons (one on each line) for JSP page using Struts2 , [question]: Get value from a row in a JSP page using display tag , [question]: Retrieving Value from Row in Struts2 Table While using Displaytag), but I could not find a solution that works for me.



And google gave me ( http://demo.displaytag.org/displaytag-examples-1.2/example-decorator-link.jsp ), but it uses URL rewriting which I don't want to use and moreover demonstrates use with struts(I am using struts 2).



My jsp structure and what I am currently trying is :



<s:url id=editReport action=editReport />
<sd:div href=%{editReport} listenTopics=editReport formId=actionForm showLoadingText=false preload=false>
<s:url id=updLists action=updLists />
<sd:div href=%{updLists} listenTopics=updLists formId=enterDayReport showLoadingText=false preload=false>
<s:form id=enterDayReport action=enterDayReport>
<sd:autocompleter label=Customer name=customer list=customerList valueNotifyTopics=updLists autoComplete=false searchType=substring/>
<sd:autocompleter label=Contact name=contact list=contactList valueNotifyTopics=updLists autoComplete=false searchType=substring/>
<s:select label=Stage name=stage list=stageList headerKey=0 headerValue=Select />
<s:select label=Type name=type list=typeList headerKey=0 headerValue=Select />
<sd:datetimepicker label=Date name=date formatLength=small displayFormat=dd - MMM - yyyy/>
<s:textarea label=Summary name=summary cols=40 rows=10/>
<s:submit value=Save Report/>
</s:form>
</sd:div>
</sd:div>

<s:url id=deleteReport action=deleteReport />
<sd:div href=%{deleteReport} listenTopics=deleteReport formId=actionForm showLoadingText=false preload=false>
<disp:table name=dayReportsList export=true class=dataTable>
<disp:column property=contactCode title=Contact/>
<disp:column property=customerCode title=Customer/>
<disp:column property=stage title=Stage/>
<disp:column property=type title=Type/>
<disp:column property=summary title=Summary/>
<disp:column property=reportDate title=Date format={0,date,dd-MMM-yyyy} />
<disp:column property=rowId href=%{editReport} paramId=rowID paramProperty=rowId title=Action>
<s:form id=actionForm name=actionForm>
<s:hidden id=rowId name=rowId value=%{rowId}/> // This is not getting populated.
<s:a onclick=dojo.event.topic.publish('editReport')>Edit<s:property value=rowId/></s:a><br>
<s:a onclick=dojo.event.topic.publish('deleteReport')>Delete</s:a>
</s:form>
</disp:column>
</disp:table>
</sd:div>


Here the only problem I am facing is that the hidden field in the display tag table is not getting populated with the rowId value which is a part of dayReportsList.



The idea here is that if a user clicks on edit, the data for the row gets populated in the form for editing. And if the user clicks delete, the row gets deleted from the database and the display table gets updated on JSP.



Please advise.



Thanks!!


More From » jsp

 Answers
166

The current element of the list is available through the page context attribute foobar if the display:table tag has the attribute uid=foobar (or id=foobar). See http://www.displaytag.org/1.2/displaytag/tagreference.html


[#88561] Tuesday, December 13, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leog

Total Points: 225
Total Questions: 113
Total Answers: 118

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;