I have "ajaxish" javascript code working by row in a displaytag table. Here's my code, though it has some proprietary tag code in it too. But it should help:
<display:column headerClass="data" class="data_left" title="Student Name"> <div id="name_${row.id}"> <c:choose> <c:when test="${empty matches[row.id]}"> <premis:comboBox name="examStudent_${row.id}" items="${missingExam}" onchange="studentChanged(this);"/> </c:when> <c:otherwise> <input type="hidden" name="student_${row.id}" value="${(matches[row.id]).id}"/> ${(matches[row.id]).person.name.formatted} </c:otherwise> </c:choose> </div> </display:column> The magic here is that each row has a combobox called "examStudent_XXX" where XXX is the id of the record, the onchange event calls a javascript function "studentChanged" that takes the value of the selected combobox row. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tstronge Sent: Tuesday, November 20, 2007 9:45 AM To: displaytag-user@lists.sourceforge.net Subject: Re: [displaytag-user] Using Link on Column to populate fields (plural!) in parent screen I got a bit carried away with enthusiasm ;-( What I got it to work yesterday only had one row in the table (the single thus last row in the table!). However, on trying it with multiple rows in the table I realised that I cannot get at the correct row object. My tstronge wrote: > > String fieldValue = evaluate(listObjFieldName, > ctxt.getAttribute("tableRow")).toString(); > doesn't work because ctxt.getAttribute("tableRow") gives me the item in the last row of the table and not the item that's being selected by the user clicking on the link. So I'm back to square 1 - I can't use a TableDecorator as I don't know the column name up front to write a getSomeColumnName() method in the table decorator - I can't use a ColumnDecorator as I can't access values other than the column in question Any help really appreciated on this as I am losing hairs by the hour!! My latest (failed!) attempt has > public Object decorate(Object columnValue, PageContext ctxt, > MediaTypeEnum mt) throws DecoratorException { > String returnAssignmentsStr = ""; > > String[] returnValueAssignmentPairs = (String[]) > ctxt.getAttribute("returnValueAssignmentPairs"); > > for (int i = 0; i < returnValueAssignmentPairs.length; i++) { > String parentObjFieldName = > returnValueAssignmentPairs[i].split("=")[0]; > String listObjFieldName = > returnValueAssignmentPairs[i].split("=")[1]; > > String fieldValue = evaluate(listObjFieldName, > ctxt.getAttribute("selection")).toString(); > > returnAssignmentsStr = returnAssignmentsStr + parentObjFieldName + > "=" + fieldValue; > if (i < returnValueAssignmentPairs.length - 1) { > returnAssignmentsStr += ";"; > } > } > > return "<a href=\"#\" class=\"DATA-LINK\" > onclick=\"javascript:populate_parent('" + returnAssignmentsStr + > "')\">" > + columnValue.toString() + "</a>"; > } > in the ColumnDecorator and > <display:column media="html" > property="${columnName}" > .... blah .... > decorator="com.XXXX.XXXX.XX.web.decorator.ReturnValueLinkColumnDecorator " > > > </display:column> > in the JSP -- View this message in context: http://www.nabble.com/Using-Link-on-Column-to-populate-fields-%28plural% 21%29-in-parent-screen-tf4811614.html#a13858332 Sent from the DisplayTag - General mailing list archive at Nabble.com. ------------------------------------------------------------------------ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ displaytag-user mailing list displaytag-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/displaytag-user ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ displaytag-user mailing list displaytag-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/displaytag-user