Nick Westgate wrote:
Ok, here is a solution. Took me 5 minutes to write, 20 mins to test. ;-)
Oh. I should have attempt to do it :) thank you very much, works like a
charm :)
Yeah, this is exactly what I have implemented. Eventually a shared hidden
input should probably be used, but I can't see (or perhaps grok) the form
support for this yet. Also a context that is a list of objects was my
plan,
but the context "passivation" is all internal and relies on the
TypeCoercer
stuff which is a bit involved. This should do for a first cut.
Well, I need at least to deals with List<String> argument, even if it is
as a (two) simple way, so a change your code as wrote at the end of the
message. The string of the list are concatenated in the same way a for
an action link (ex: "value0/value1/value2") so that in the event
handler, a split give me the different argument. Well, it's clearly not
robust, it would be better to use TypeCoercer and some other remarks,
but for now, it would be greatly better to use.
Thanks again for your time !
And thanks to Tapestry developers for the ease of use of T5 !
The code :
8<-------------------------
@Parameter
private String _context;
==================>
@Parameter
private List<String> _context;
8<-------------------------
8<-------------------------
void beginRender(MarkupWriter writer)
{
// write a hidden input for the context
String elementName = getElementName();
writer.element("input", "type", "hidden", "name", elementName +
"X", "value", _context);
writer.end();
// now the submit
writer.element("input", "type", "submit", "name", elementName,
"id", getClientId());
}
==================>
void beginRender(MarkupWriter writer)
{
/* convert context to a string :
context[0]/context[1]/context[2] ... */
StringBuilder contextStringBuilder = new StringBuilder("");
if(null != _context) {
int j;
for(int i = 0; (j = _context.size()-i) > 0 ;i++) {
contextStringBuilder.append(_context.get(i));
if(j >1) { contextStringBuilder.append("/"); }
}
}
// write a hidden input for the context
String elementName = getElementName();
writer.element("input", "type", "hidden", "name", elementName +
"X", "value", contextStringBuilder.toString());
writer.end();
// now the submit
writer.element("input", "type", "submit", "name", elementName,
"id", getClientId());
}
8<-------------------------
Diff it to Submit and you'll see it's only a few extra lines. Hope it
helps.
Cheers,
Nick.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]