Hello!
I'm still having some trouble with my test-application and IE.
The intended functionality is the following:
Page consists out of three PropertySelections, one TextField and one
Checkbox.
PropertySelection 1 affects the content of PropertySelection 2 and
possibly the content of PropertySelection 3
PropertySelection 2 affects the content of PropertySelection 3
PropertySeleciton 3 affects both TextField and Checkbox.
Using Firefox, the components get updated as they should.
However, using IE doesn't work. The EventListener gets called on the
first change of Selection 1, but the other Components don't get updated.
If i change the value of that Selection again, the application crashes
before the EventListener is called. Additionally the (should be)
affected PropertySelections don't get updated during the run of the
EventListener. If there was a working Selection before in one of the
affected Selections, these are gone after the first EventListener-call
as well.
I'm using last nights svn-snapshot of Tapestry for testing.
Did i miss something or is there really a problem with Tapestry411/AJAX
and IE?
Patrick
----------- Test Page -----------------
The html-template looks like this:
<html jwcid="@Shell" title="TestPage">
<body jwcid="@Body">
<h1>Test...</h1>
<form jwcid="[EMAIL PROTECTED]">
Page Counter: <div jwcid="@Insert" value="ognl:counter"/>
<div jwcid="[EMAIL PROTECTED]" id="button"
listener="listener:button" value="Press Me"/>
</form>
<form jwcid="[EMAIL PROTECTED]" async="ognl:true"
updateComponents="ognl:updateComponentsSingle">
<br/><br/>
<br/><br/>
<div jwcid="@PropertySelection" id="testSelection"
model="ognl:testModel" value="ognl:test"/>
<div jwcid="@PropertySelection" id="resultSelection"
model="ognl:resultModel" value="ognl:result"/>
<div jwcid="@PropertySelection" id="targetSelection"
model="ognl:targetModel" value="ognl:target"/>
<div jwcid="@Any" id="updateMe">
<div jwcid="@TextField" id="output" value="ognl:output"/>
</div>
<div jwcid="@Any" id="updateBool">
<div jwcid="@Checkbox" id="outBool" value="ognl:outBool"
disabled="ognl:true"/>
</div>
<br/><br/>
<br/><br/>
</form>
<span jwcid="@contrib:InspectorButton" disabled="ognl:false"/>
</body>
</html>
The Java-class has the following content:
package test;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.EventListener;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.BrowserEvent;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.form.IPropertySelectionModel;
import org.apache.tapestry.html.BasePage;
public abstract class Home extends BasePage implements
PageBeginRenderListener {
public void pageBeginRender(PageEvent event) {
if (getResultModel() == null) {
fillResultModel();
}
if (getTargetModel() == null) {
fillTargetModel();
}
}
public String getCallingElementId(BrowserEvent event) {
return (String) event.getTarget().get(BrowserEvent.TARGET_ATTR_ID);
}
// /////////////////////////////////////////////
// generate/build the needed Selection-Models //
// /////////////////////////////////////////////
public void fillResultModel() {
setResultModel(getResultModel(getTest()));
}
public IPropertySelectionModel getResultModel(Test test) {
List<Enum> resultingList = new ArrayList<Enum>();
resultingList.add(null);
if (test != null) {
switch (test) {
case TEST1:
resultingList.add(Result.RESULT1);
resultingList.add(Result.RESULT3);
break;
case TEST2:
resultingList.add(Result.RESULT2);
resultingList.add(Result.RESULT4);
break;
case TEST3:
resultingList.add(Result.RESULT3);
resultingList.add(Result.RESULT1);
break;
case TEST4:
resultingList.add(Result.RESULT4);
resultingList.add(Result.RESULT2);
break;
}
}
return new EnumerationSelectionModel(resultingList
.toArray(new Enum[resultingList.size()]));
}
public IPropertySelectionModel getTestModel() {
List<Enum> resultingList = new ArrayList<Enum>();
resultingList.add(null);
Enum[] temp = Test.values();
for (int i = 0; i < temp.length; i++) {
resultingList.add(temp[i]);
}
return new EnumerationSelectionModel(resultingList
.toArray(new Enum[resultingList.size()]));
}
public void fillTargetModel() {
if (!Result.RESULT4.equals(getResult())) {
setOutput(null);
setOutBool(false);
}
setTargetModel(getTargetModel(getResult()));
}
public IPropertySelectionModel getTargetModel(Result result) {
List<Enum> resultingList = new ArrayList<Enum>();
resultingList.add(null);
if (Result.RESULT4.equals(result)) {
Enum[] temp = Target.values();
for (int i = 0; i < temp.length; i++) {
resultingList.add(temp[i]);
}
} else {
setOutput(null);
}
return new EnumerationSelectionModel(resultingList
.toArray(new Enum[resultingList.size()]));
}
// ///////////////////////////////////////////////////////////////
// Event Listener for the Single Data Case (working, except IE) //
// ///////////////////////////////////////////////////////////////
@EventListener(elements = "testSelection", events = "onchange",
submitForm = "testFormSingle", async = true)
public void adjustResultModel(BrowserEvent event) {
System.out.println("adjustResultModel called. Counter = "
+ getCounter());
if (getTest() == null) {
setResult(null);
} else {
switch (getTest()) {
case TEST1:
case TEST3:
if (Result.RESULT2.equals(getResult())
|| Result.RESULT4.equals(getResult())) {
setResult(null);
}
setTarget(null);
break;
case TEST2:
case TEST4:
if (Result.RESULT1.equals(getResult())
|| Result.RESULT3.equals(getResult())) {
setResult(null);
}
if (!Result.RESULT4.equals(getResult())) {
setResult(null);
}
break;
}
}
fillResultModel();
fillTargetModel();
getRequestCycle().getResponseBuilder().updateComponent(
"resultSelection");
getRequestCycle().getResponseBuilder().updateComponent(
"targetSelection");
if (getCounter() == null) {
setCounter(0);
} else {
Integer counter = getCounter();
counter++;
setCounter(counter);
}
}
@EventListener(elements = "resultSelection", events = "onchange",
submitForm = "testFormSingle", async = true)
public void adjustTargetModel(BrowserEvent event) {
System.out.println("adjustTargetModel called. Counter = "
+ getCounter());
// update TargetSeleections
fillTargetModel();
getRequestCycle().getResponseBuilder().updateComponent(
"targetSelection");
// getRequestCycle().getResponseBuilder().updateComponent("output");
getRequestCycle().getResponseBuilder().updateComponent("updateMe");
getRequestCycle().getResponseBuilder().updateComponent("updateBool");
//
getRequestCycle().getResponseBuilder().updateComponent("myFavoriteDiv");
if (getCounter() == null) {
setCounter(0);
} else {
Integer counter = getCounter();
counter++;
setCounter(counter);
}
}
@EventListener(elements = "targetSelection", events = "onchange",
submitForm = "testFormSingle", async = true)
public void adjustOutput() {
System.out.println("adjustOutput called. Counter = " +
getCounter());
// update TargetSeleections
if (getTarget() == null) {
setOutput(null);
setOutBool(false);
} else {
setOutput(getTarget().toString());
setOutBool(Target.RI1.equals(getTarget()));
}
// getRequestCycle().getResponseBuilder().updateComponent("output");
getRequestCycle().getResponseBuilder().updateComponent("updateMe");
getRequestCycle().getResponseBuilder().updateComponent("updateBool");
//
getRequestCycle().getResponseBuilder().updateComponent("myFavoriteDiv");
if (getCounter() == null) {
setCounter(0);
} else {
Integer counter = getCounter();
counter++;
setCounter(counter);
}
}
public void button(IRequestCycle cycle) {
System.out.println("Button has been pressed");
if (getCounter() == null) {
setCounter(0);
} else {
Integer counter = getCounter();
counter++;
setCounter(counter);
}
// should only update the data
return;
}
public String[] getUpdateComponentsSingle() {
List<String> componentList = new ArrayList<String>();
componentList.add("resultSelection");
componentList.add("targetSelection");
componentList.add("output");
componentList.add("updateMe");
componentList.add("outBool");
componentList.add("updateBool");
return componentList.toArray(new String[componentList.size()]);
}
// Iterator used
@Persist
public abstract Integer getCounter();
public abstract void setCounter(Integer counter);
public abstract IPropertySelectionModel getResultModel();
public abstract void setResultModel(IPropertySelectionModel model);
public abstract IPropertySelectionModel getTargetModel();
public abstract void setTargetModel(IPropertySelectionModel model);
@Persist
public abstract Test getTest();
public abstract void setTest(Test test);
@Persist
public abstract Result getResult();
public abstract void setResult(Result test);
public abstract Target getTarget();
public abstract void setTarget(Target target);
public abstract String getOutput();
public abstract void setOutput(String output);
public abstract boolean getOutBool();
public abstract void setOutBool(boolean bool);
}
The page-file only contains the class-definition.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]