Your placeHolder hast to be a Tapestry component not just a div
container. Just replace id="placeHolder" with jwcid="[EMAIL PROTECTED]"
and it should work.
Uli
Andy Pahne schrieb:
I am trying to show some parts of a page that were initially hidden,
depending on some event that is asynchronously submitted through the
@EventListener feature.
Unfortunatly the hidden form field never shows up. I am not sure if
there's a problem with my code or if my approach is correct at all. Any
other ideas are welcome.
My template:
----------------------
<span jwcid="@PublicBorder">
<h1>Form Demo</h1>
<form jwcid="formComponent">
<input type="text" jwcid="formField1"/><br>
<input type="text" jwcid="formField2"/><br>
<div id="placeHolder">
<span jwcid="conditionalBlock">
<input type="text" jwcid="formField3"/><br>
</span>
</div>
<input jwcid="submitter"/>
</form>
</span>
------------------------
The page class:
------------------------
package xxx.oos.web.pages.test;
import componentFactory.page.BasePage;
import xxx.oos.web.OosValidationDelegate;
public abstract class AjaxTest2 extends BasePage{
private static final Logger LOG = Logger.getLogger(AjaxTest2.class);
@Bean(OosValidationDelegate.class)
public abstract IValidationDelegate getDelegate();
public abstract String getValue1();
public abstract String getValue2();
public abstract String getValue3();
public abstract void setValue3(String newValue);
@InitialValue("ognl:false")
public abstract boolean isShowHiddenPart();
public abstract void setShowHiddenPart(boolean showIt);
@Component(
type="Form", id="formComponent")
public abstract IComponent getFormComponent();
@Component(type="TextField", id="formField1",
bindings = {
"value=ognl:value1"
})
public abstract IComponent getFormField1();
@Component(type="TextField", id="formField2",
bindings = {
"value=ognl:value2"
})
public abstract IComponent getFormField2();
@Component(type="TextField", id="formField3",
bindings = {
"value=ognl:value3"
})
public abstract IComponent getFormField3();
@Component(type="If", id="conditionalBlock",
bindings = {
"condition=ognl:showHiddenPart",
"renderTag=ognl:true"
})
public abstract IComponent getConditionalBlock();
@Component(type="Submit", id="submitter",
bindings = {
"listener=listener:submitForm"
})
public abstract IComponent getSubmitter();
public void submitForm() {
LOG.info("form submitted");
}
@EventListener(
targets = "formField1",
events = "onchange",
async=true,
autoSubmit=false)
public void changeField1(BrowserEvent event) {
LOG.info("field 1 has changed");
LOG.info("new value is '" + getValue1() + "'");
updateField3(getRequestCycle());
}
private void updateField3(IRequestCycle requestCycle) {
LOG.info("updating field3 and showing it...");
setValue3(getValue1());
setShowHiddenPart(true);
requestCycle.getResponseBuilder().updateComponent("placeHolder");
}
}
------------------------
The Logging Output after changing field1
------------------------
INFO (AjaxTest2.java:90) - field 1 has changed
INFO (AjaxTest2.java:91) - new value is 'uztuzz'
INFO (AjaxTest2.java:96) - updating field3 and showing it...
------------------------
The Debug Output after changing field1
------------------------
DEBUG: 12:01:45 PM: tapestry.load() Response received.
------------------------
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]