You'll probably want to contribute it to AjaxComponentEventResultProcessor 
though.

On 08.07.2010 12:36, Christophe Cordenier wrote:
Hi

You will have to create your own ComponentEventResultProcessor and
contribute it in your AppModule class :

public void contributeComponentEventResultProcessor(
             MappedConfiguration<Class, ComponentEventResultProcessor>
configuration) {

   configuration.addInstance(net.sf.json.JSONObject.class,
YouProcessor.class);

}

2010/7/8 Borut Bolčina<borut.bolc...@gmail.com>

Hello,

Is it possible to configure return types?

In one of my event methods I was trying to return net.sf.json.JSONObject
instead of org.apache.tapestry5.json.JSONObject and got this error message:

[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
with uncaught exception: A component event handler method returned the
value

{"birthDay":"","birthMonth":"","birthYear":"","gender":"male","postOfficeNumberAndName":"1236
Trzin"}. Return type net.sf.json.JSONObject can not be handled.  Configured
return types are java.lang.Class, java.lang.String,
org.apache.tapestry5.Link, org.apache.tapestry5.StreamResponse,
org.apache.tapestry5.ajax.MultiZoneUpdate,
org.apache.tapestry5.json.JSONArray, org.apache.tapestry5.json.JSONObject,
org.apache.tapestry5.runtime.Component,
org.apache.tapestry5.runtime.RenderCommand.
org.apache.tapestry5.runtime.ComponentEventException: A component event
handler method returned the value

{"birthDay":"","birthMonth":"","birthYear":"","gender":"male","postOfficeNumberAndName":"1236
Trzin"}. Return type net.sf.json.JSONObject can not be handled.  Configured
return types are java.lang.Class, java.lang.String,
org.apache.tapestry5.Link, org.apache.tapestry5.StreamResponse,
org.apache.tapestry5.ajax.MultiZoneUpdate,
org.apache.tapestry5.json.JSONArray, org.apache.tapestry5.json.JSONObject,
org.apache.tapestry5.runtime.Component,
org.apache.tapestry5.runtime.RenderCommand. [at context:Index.tml, line 20]


My event method:

    @OnEvent(component = "email", value = "blur")
    public JSONObject checkIfUserWithThisEmailExists(String value) {
        UserData userData = new UserData();
        if(value.equals("b...@example.com")) {
            userData.setPostOfficeNumberAndName("1236 Trzin");
            userData.setGender("male");
        } else {
            logger.info("Bob does not exist.");
        }
        JSONObject jsonObject = (JSONObject)
JSONSerializer.toJSON(userData);
        return jsonObject;
    }

The reason I used net.sf.json.JSONObject is because it offers great
conversion and construction capabilities to/from JavaBeans/XML/JSON. Have a
look at http://json-lib.sourceforge.net/snippets.html.

Is it possible or do I have to construct the org.apache.tapestry5.json.JSON
object by hand?

Thanks,
Borut





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to