You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joe123 --- <jp...@hotmail.com> on 2008/12/17 18:44:59 UTC
t5Components + Return JSONArray to component
I used the T5Components OnEvent. But for some reason I don't get the JSONArray as a response in the javascript code.
I can see the javascript is called, but the response is "Undefined". I have no clue what causes the problem. And am struggling with this issue for a couple of days. I upgraded to tapestry 5.0.18. I had this working in an earlier version of tapestry and t5components.
@OnEvent(component = "operator", value = "change")
public JSONArray onChangeOperatorEvent(String value) {
JSONArray jsonArray = new JSONArray();
for (Plaza plaza : getDestinationSelectValues(value)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", plaza.getId());
jsonObject.put("label", plaza.getDescription());
jsonArray.put(jsonObject);
}
return jsonArray;
}
Finally, the onCompleteOperatorChange javascript function has to parse the return JSON and update the select input options:
function onCompleteOperatorChange(response) {
selectElement = $("entryPlaza");
responseJSON = response.evalJSON();
while (selectElement .options.length > 0) {
selectElement .options[0] = null;
}
for (index = 0; index < responseJSON .length; index++) {
selectElement.options[index] = new Option(responseJSON[index].label, responseJSON [index].value);
}
Tapestry.ElementEffect.highlight($("entryPlaza"));
}
But the response is "Undefined" .
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us