You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrik Westlund <pa...@lemonlime.se> on 2005/06/29 12:05:37 UTC
Finding component name in script?
I have written a component consisting of a Select component and three
Submit buttons (Add,Edit,Delete). Works fine. Now I want to enable and
disable the buttons from javascript depending on if any item in the
Select component is selected by the user. How can I find the names of
the submit buttons so I can pass these to my script?
The code is very similar to the tapestry-contrib Palette component.
---
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
// Other stuff here
if (!cycle.isRewinding()) {
symbols = new HashMap(MAP_SIZE);
runScript(cycle);
}
super.renderComponent(writer, cycle);
}
private void runScript(IRequestCycle cycle) {
if (script == null) {
IEngine engine = getPage().getEngine();
IScriptSource source = engine.getScriptSource();
IResourceLocation specificationLocation =
getSpecification().getSpecificationLocation();
IResourceLocation scriptLocation =
specificationLocation.getRelativeLocation("SortList.script");
script = source.getScript(scriptLocation);
}
Body body = Body.get(cycle);
IForm form = Form.get(cycle);
symbols.put("sortList", this);
IFormComponent addBtn = (IFormComponent) getComponent("addButton");
symbols.put("addButtonName", addBtn.getName());
script.execute(cycle, body, symbols);
}
---
But since the script is executed before the submit buttons are rendered
the names are not known. Is there some way to find the name for the
submit and pass it to the script? Or maybe set a name explicitly for
button and script?
Regards,
Patrik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org