Re: Realize operations on "blur" from a textfield
Hi Claude, you can use chenillekit mixin OnEvent (). Here is the link: http://www.chenillekit.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html If you are developing with Tapestry 5.1, then put org.chenillekit chenillekit-tapestry 1.2.0 jboss javassist in your POM. In your template use the mixin on the input field: : Then in your class: @IncludeJavaScriptLibrary("context:js/util.js") public class Index { ... @Property private String email; ... @OnEvent(component = "email", value = "blur") public JSONObject checkIfUserWithThisEmailExists(String value) { UserData userData = new UserData(); if(value.equals("b...@example.com")) { logger.info("Exists."); userData.setPostOfficeNumberAndName("1236 Trzin"); userData.setGender("male"); userData.setBirthDay("29"); userData.setBirthMonth("4"); userData.setBirthYear("1973"); } else { logger.info("Bob does not exist."); } JSONObject jsonObject = new JSONObject(JSONSerializer.toJSON(userData).toString()); return jsonObject; } ... Create util.js in src/main/webapp/js and put the callback function which updates your page's data in there, like: function onCompletePrefillInputFields(response) { Tapestry.debug("onCompletePrefillInputFields():" + response.postOfficeNumberAndName); Tapestry.debug("onCompletePrefillInputFields():" + response.gender); Tapestry.debug("onCompletePrefillInputFields():" + response.birthDay); Tapestry.debug("onCompletePrefillInputFields():" + response.birthMonth); Tapestry.debug("onCompletePrefillInputFields():" + response.birthYear); $('postOffice').value = response.postOfficeNumberAndName; if (response.gender == "male") { $('radioM').checked = true; } else if (response.gender == "female") { $('radioF').checked = true; } selectOptionByValue($('select'), response.birthDay); //selectOptionByValue($('select_0'), response.birthMonth); // values are month names and not a number if (response.birthMonth != "") { $('select_0').options[response.birthMonth].selected = true; // so find by index } selectOptionByValue($('select_1'), response.birthYear); } That should do it. Cheers, Borut 2010/7/8 Claude Dubois > > Hello everybody, > > I'm developing a Tapestry 5 application, and I would like to add an > autocomplete functionality, but not like the one integrated in T5. > > What I want to do is to search in my database the corresponding name of one > part from its number, e.g. to detect the "onblur" action on my textfield to > trigger this search. Once the search is over, the part name will appear in > the corresponding textfield. > > Does anyone have any idea of how it is possible to detect "onBlur" like we > could do in Javascript? > > Thank you in advance > > - > Claude Dubois > -- > View this message in context: > http://old.nabble.com/Realize-operations-on-%22blur%22-from-a-textfield-tp29106396p29106396.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: Return type net.sf.json.JSONObject can not be handled
It's more fun to create your own ResultProcessor, though :) You'll get to try out the real power of T5. On Thu, Jul 8, 2010 at 1:28 PM, Borut Bolčina wrote: > Thanks for ultra fast responses. I guess they went through > AjaxComponentEventResultProcessor :-) > > Until I try implementing the processor class, I found a compromise. > > return org.apache.tapestry5.json.JSONObject jsonObject = new > > org.apache.tapestry5.json.JSONObject(JSONSerializer.toJSON(userData).toString()); > > I found out that org.apache.tapestry5.json.JSONObject has a constructor > with > a String form of a JSON object. > > Thanks! > Borut > > > > > 2010/7/8 Ulrich Stärk > > > 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 > >> configuration) { > >> > >> configuration.addInstance(net.sf.json.JSONObject.class, > >> YouProcessor.class); > >> > >> } > >> > >> 2010/7/8 Borut Bolčina > >> > >> 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 > > > > >
Re: Disable Transfer-Encoding chunked from StreamResponse
On Thu, 08 Jul 2010 10:50:40 -0300, fdesbois wrote: I resolve my problem setting the Content-Length of the result Stream : @Override public void prepareResponse(Response response) { response.setHeader("Content-Length", "" + length); } where length = inputStream.available(); or file.length(); The Transfer-Encoding is not used anymore if Content-Length is defined :) Thanks for the info! It's a good ideea to set the content length header if you already know it, anyway. :) -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Multiple Components in
On Thu, 08 Jul 2010 10:38:51 -0300, matt22 wrote: hmmm, yes... But I want to insert components dynamically, in class: TML: Two suggestions: 1) Implement a RenderCommand that adds the Blocks to the RenderQueue and return it in getListOfComponents(). You'll need to cast the blocks to RenderCommand. 2) Implement a component that receives the blocks to be rendered. It's beginRender() method will return the current block (Tapestry will render it) and your afterRender() method will return false if not all blocks were rendered yet. As Kristian said, you can't instantiate components yourself, but you can render them dinamically. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Disable Transfer-Encoding chunked from StreamResponse
Le Thu, 08 Jul 2010 08:56:12 -0300, "Thiago H. de Paula Figueiredo" a écrit : > On Thu, 08 Jul 2010 08:34:06 -0300, fdesbois > wrote: > > > Hi, > > Hi! > > > How can I disable Transfer-Encoding chunked ? I tried to do this in > > the StreamResponse : > > I really don't know the answer, but I guess this is related to the > server configuration, not Tapestry-related. > I resolve my problem setting the Content-Length of the result Stream : @Override public void prepareResponse(Response response) { response.setHeader("Content-Length", "" + length); } where length = inputStream.available(); or file.length(); The Transfer-Encoding is not used anymore if Content-Length is defined :) -- Florian Desbois SSLL Code Lutin http://www.codelutin.com tel : 02 40 50 29 28 Réseau Libre-Entreprise - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Multiple Components in
tapestry does not support dynamic component creation... for good reason please search the user list for "static structure, dynamic behaviour" to get more information on that. g, kris Von:matt22 An: users@tapestry.apache.org Datum: 08.07.2010 15:39 Betreff:Re: Multiple Components in > correct... create a block with multiple coponents > > g, > kris > > > > Von:matt22 > An: users@tapestry.apache.org > Datum: 08.07.2010 07:15 > Betreff:Multiple Components in > > > > Hi, > Is it possible to render list of component in delegate? > > or create new block and add component to the new block(and render the > block > in delegate)? > > thanks > -- > View this message in context: > http://old.nabble.com/Multiple-Components-in-%3Ct%3Adelegate-...-tp29100029p29100029.html > > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > -- View this message in context: http://old.nabble.com/Multiple-Components-in-%3Ct%3Adelegate-...-tp29100029p29107138.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Multiple Components in
hmmm, yes... But I want to insert components dynamically, in class: TML: > correct... create a block with multiple coponents > > g, > kris > > > > Von:matt22 > An: users@tapestry.apache.org > Datum: 08.07.2010 07:15 > Betreff:Multiple Components in > > > > Hi, > Is it possible to render list of component in delegate? > > or create new block and add component to the new block(and render the > block > in delegate)? > > thanks > -- > View this message in context: > http://old.nabble.com/Multiple-Components-in-%3Ct%3Adelegate-...-tp29100029p29100029.html > > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > -- View this message in context: http://old.nabble.com/Multiple-Components-in-%3Ct%3Adelegate-...-tp29100029p29107138.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Realize operations on "blur" from a textfield
Your problem is almost identical to the problem of doing client-side validation with AJAX. I think this will provide most of the solution: http://jumpstart.doublenegative.com.au/jumpstart/examples/input/ajaxvalidators1 You'd replace CustomError with your textfield. CustomError is listed in: http://jumpstart.doublenegative.com.au/jumpstart/examples/input/novalidationbubbles1 Cheers, Geoff On 08/07/2010, at 10:18 PM, Claude Dubois wrote: > > Hello everybody, > > I'm developing a Tapestry 5 application, and I would like to add an > autocomplete functionality, but not like the one integrated in T5. > > What I want to do is to search in my database the corresponding name of one > part from its number, e.g. to detect the "onblur" action on my textfield to > trigger this search. Once the search is over, the part name will appear in > the corresponding textfield. > > Does anyone have any idea of how it is possible to detect "onBlur" like we > could do in Javascript? > > Thank you in advance > > - > Claude Dubois > -- > View this message in context: > http://old.nabble.com/Realize-operations-on-%22blur%22-from-a-textfield-tp29106396p29106396.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Realize operations on "blur" from a textfield
On Thu, 08 Jul 2010 09:18:12 -0300, Claude Dubois wrote: Does anyone have any idea of how it is possible to detect "onBlur" like we could do in Javascript? Tapestry works on the server-side, so you need to listen to the Javascript event yourself then trigger a server-side event to process it. Check the examples in JumpStart: http://jumpstart.doublenegative.com.au/jumpstart/ -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Realize operations on "blur" from a textfield
Hello everybody, I'm developing a Tapestry 5 application, and I would like to add an autocomplete functionality, but not like the one integrated in T5. What I want to do is to search in my database the corresponding name of one part from its number, e.g. to detect the "onblur" action on my textfield to trigger this search. Once the search is over, the part name will appear in the corresponding textfield. Does anyone have any idea of how it is possible to detect "onBlur" like we could do in Javascript? Thank you in advance - Claude Dubois -- View this message in context: http://old.nabble.com/Realize-operations-on-%22blur%22-from-a-textfield-tp29106396p29106396.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Disable Transfer-Encoding chunked from StreamResponse
Le Thu, 08 Jul 2010 08:56:12 -0300, "Thiago H. de Paula Figueiredo" a écrit : > On Thu, 08 Jul 2010 08:34:06 -0300, fdesbois > wrote: > > > Hi, > > Hi! > > > How can I disable Transfer-Encoding chunked ? I tried to do this in > > the StreamResponse : > > I really don't know the answer, but I guess this is related to the > server configuration, not Tapestry-related. > Damn'it, thx Thiago... A configuration may be exists in web.xml, but I find nowhere how to do it... -- Florian Desbois SSLL Code Lutin http://www.codelutin.com tel : 02 40 50 29 28 Réseau Libre-Entreprise - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Disable Transfer-Encoding chunked from StreamResponse
On Thu, 08 Jul 2010 08:34:06 -0300, fdesbois wrote: Hi, Hi! How can I disable Transfer-Encoding chunked ? I tried to do this in the StreamResponse : I really don't know the answer, but I guess this is related to the server configuration, not Tapestry-related. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Inject in SetupRender?
On Thu, 08 Jul 2010 02:25:03 -0300, matt22 wrote: Hi, Hi! Is it possible to inject componets in setupRender, or beginRender? You can only inject components in classes using the @InjectComponent annotation. If in layout i have 5 components and i want to inject only some of the components(depends on DBS settings). It doesn't make a difference injecting 1 or 100 components. All them are already instantiated in the page or component. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Disable Transfer-Encoding chunked from StreamResponse
Hi, I have a problem with Transfer-Encoding chunked on an kml/xml file. I need to disable it to use the full response as one element for OpenLayers javascript framework. How can I disable Transfer-Encoding chunked ? I tried to do this in the StreamResponse : @Override public void prepareResponse(Response response) { response.setHeader("Transfer-Encoding", null); } but the Transfer-Encoding still appears in firebug... Server Apache-Coyote/1.1 Content-Typeapplication/vnd.google-earth.kml+xml Transfer-Encoding chunked DateThu, 08 Jul 2010 11:32:07 GMT -- Florian Desbois SSLL Code Lutin http://www.codelutin.com tel : 02 40 50 29 28 Réseau Libre-Entreprise - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Return type net.sf.json.JSONObject can not be handled
Thanks for ultra fast responses. I guess they went through AjaxComponentEventResultProcessor :-) Until I try implementing the processor class, I found a compromise. return org.apache.tapestry5.json.JSONObject jsonObject = new org.apache.tapestry5.json.JSONObject(JSONSerializer.toJSON(userData).toString()); I found out that org.apache.tapestry5.json.JSONObject has a constructor with a String form of a JSON object. Thanks! Borut > 2010/7/8 Ulrich Stärk > 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 >> configuration) { >> >> configuration.addInstance(net.sf.json.JSONObject.class, >> YouProcessor.class); >> >> } >> >> 2010/7/8 Borut Bolčina >> >> 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 > >
Re: Return type net.sf.json.JSONObject can not be handled
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 configuration) { configuration.addInstance(net.sf.json.JSONObject.class, YouProcessor.class); } 2010/7/8 Borut Bolčina 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
Re: Return type net.sf.json.JSONObject can not be handled
Hi You will have to create your own ComponentEventResultProcessor and contribute it in your AppModule class : public void contributeComponentEventResultProcessor( MappedConfiguration configuration) { configuration.addInstance(net.sf.json.JSONObject.class, YouProcessor.class); } 2010/7/8 Borut Bolčina > 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 > -- Regards, Christophe Cordenier. Committer on Apache Tapestry 5 Co-creator of wooki @wookicentral.com
Return type net.sf.json.JSONObject can not be handled
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
Re: Inject in SetupRender?
add an If-component to your page class like this @Component(parameters = {"test=whatever"} private If ifWhateverIsTrue and put your components in you page-template between the if-tag like this: . put you components/html code here .. with regards Sven Homburg Founder of the Chenille Kit Project http://chenillekit.codehaus.org 2010/7/8 matt22 > > Hi, > Is it possible to inject componets in setupRender, or beginRender? > > If in layout i have 5 components and i want to inject only some of the > components(depends on DBS settings). > > thanks for any suggestion in advance, > > and sorry for my terrible english, thanks.. :) > -- > View this message in context: > http://old.nabble.com/Inject-in-SetupRender--tp29100030p29100030.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: [T5.2] Tapestry.remove() js function causes exception IE7
Hi, Doing some more debugging I would that element.remove == null. The whole function doesn't exist on the element. When I add a null check, I run into a similair problem on the formFragment where element.isDeepVisible == null. In IE8 I also encounter the problem as described in https://issues.apache.org/jira/browse/TAP5-1192 Before I dive in too deep can anyone comment on the state of tapestry.js in the trunk? Has it been tested against IE7 and IE8? Thanks, Joost Joost Schouten (ml) wrote: Hi, Recently I started experiencing problems when clicking the remove button in the AjaxFormLoop in IE7. I traced it down to something with: "formLoopRemoveLink effect.options.afterFinish" calling "Tapestry.remove" In the remove function the element is there, but I get a object not recognized on the element.remove function. Has anyone else experienced these problems and found a solution? Cheers, Joost - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
[T5.1]Add a field specific error message using beforeLabel
Hi everybody! I'm facing a problem I can't resolve, even after hours of reflexion and tests so I'm asking for help :) Here is my need : I would like to display the error message corresponding to each field of my form just above the label of this field. I've made some research and have found a very interesting post of Thiago about custom ValidationDecorator. I created mine, added it to my AppModule and everything should be ok. Here is the specific part of my ValidationDecorator : @Override public void beforeLabel(Field field) { if (inError(field)) { markupWriter.element("div", "class", "single-error-message"); ValidationTracker tracker = environment.peekRequired(ValidationTracker.class); markupWriter.write(tracker.getError(field)); markupWriter.end(); } } The problem is that, for a field in error (i.e. required field that is empty), when the label renders itself and call the beforeLabel() method, the field is not considered as in error (inError(field) returns false). I've checked and in the insideLabel() method, the field is in error but it's too late to use markupwriter as the label is already rendered. Finally I tried to manipulate DOM but it doesn't work too... (I'll eventually post the corresponding code later but it's not the main point of this mail). So my question is : is there a way to recognize that the field is in error in the beforeLabel() method? Thanks in advance for help! Thomas
Access to the event handler method annotation during rendering of compoment
Hi Is it possible to get access to the event handler method annotation during rendering of compoment, which triggers corresponding event ? How is it possible (the best way) ? Let say I have a custom link component SecuredLink placed in TestPage and event handler for SecuredLink event on the same page. I would like to access @Secured annotation content during render of SecuredLink compoment (to be able to make the link conditionally inaccessible). public class TestPage { @Component private SecuredLink securedLink; @Secured({Roles.ADMIN}) void onActionFromSecuredLink() { ... } ... } I know how to make "SecuredInterceptor" for the event listener method, which prevents for unauthorized invocation of the listener. As I say I would like to use annotation also during render of corresponding "triggering" component. Thanks P. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: javassist error with Tapestry 5.1.0.5 and JBoss 4.2.3GA
Make sure com.mycompany.model.User has non-args public constructor. On Thu, Jul 8, 2010 at 12:49, Halil Karakose wrote: > Changing javassist jar didn't work. I still receive the errors. > > By the way, the exception is thrown by > "org.hibernate.tuple.entity.PojoEntityTuplizer". > Is there a incompatibility with the hibernate jars? > > One more issue is that the logging level of the stack trace is in WARN > level. And I still haven't encountered anything weird in runtime. > > On Thu, Jul 1, 2010 at 9:50 AM, Joachim Van der Auwera >wrote: > > > I think you should update the javassist in jboss/server/default/lib/ > > folder. > > > > Joachim > > > > > > On 07/01/2010 08:08 AM, Halil Karakose wrote: > > > >> Hi, > >> I receive an error in my Tapestry webapp. I use Tapestry 5.1.0.5 and > Jboss > >> 4.2.3-GA. > >> > >> > >> *Scenario 1:* > >> My web application contains javassist 3.9.0.GA in WEB-INF/lib folder. > And > >> there is also another javassist.jar(3.6.0.GA) file inside > >> jboss/server/default/lib folder. > >> > >> During deployment of the web application, I receive such an exception: > >> > >> 22:12:28,373 WARN buildProxyFactory > >> [org.hibernate.tuple.entity.PojoEntityTuplizer] could not create proxy > >> factory for:com.mycompany.model.User > >> org.hibernate.HibernateException: Javassist Enhancement failed: > >> com.mycompany.model.User > >> at > >> > >> > org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:145) > >> at > >> > >> > org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:42) > >> at > >> > >> > org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162) > >> at > >> > >> > org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135) > >> at > >> > >> > org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55) > >> at > >> > >> > org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56) > >> at > >> > >> > org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302) > >> Caused by: java.lang.RuntimeException: > java.lang.IllegalArgumentException: > >> Can not set static javassist.util.proxy.MethodFilter field > >> com.mycompany.model.User_$$_javassist_5._method_filter to > >> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer$1 > >> at javassist.util.proxy.ProxyFactory.setField(ProxyFactory.java:356) > >> at > >> javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339) > >> at > >> javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:312) > >> at > >> javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:271) > >> at > >> > >> > org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:138) > >> ... 171 more > >> > >> > >> This error doesn't prevent deployment. And I have no idea what the > impact > >> of > >> this error is or will be. I can select, and insert via webapp. > >> > >> > >> *Scenario 2:* > >> If I exclude javassist 3.9.0.GA from my Tapestry webapp and leave > jboss's > >> javassist.jar in place, the application deploys without exception. But, > in > >> this case, I encounter an exception in runtime: > >> > >> org.apache.tapestry5.internal.services.TransformationException: > >> javassist.CannotCompileException: broken method > >> > >> InternalClassTransformation[ > >> > >> public com.mycompany.webapp.pages.PasswordHint extends > >> com.mycompany.webapp.pages.BasePage > >> > >> > >> > >> add method: private void _$write_logger_2(org.slf4j.Logger $1) > >> > >> throw new java.lang.RuntimeException("Field > >> com.mycompany.webapp.pages.PasswordHint.logger is read-only."); > >> > >> > >> > >> replace write logger: _$write_logger_2(); > >> .. > >> > >> > >> I am now following scenario 1, and I have not faced anything weird in > >> runtime? Any suggestions are appreciated:), > >> > >> > >> Thanks... > >> > > > -- Dmitry Gusev AnjLab Team http://anjlab.com
Re: Where to define this class?
Ahh, makes sense now. I changed all the fields to public because of that little gotcha. Josh Canfield wrote: > >> I have a class that I am using for each row in a grid, it is the mix of >> multiple entities data. the question is where to put it? > > Are you using it in more than one page? With a tiny view class I > sometimes just stick it right in the page/component that uses it. > Otherwise, like Thiago said, you need to put it in a package that's > not special to tapestry. How about /viewobject or /vo > > By the way >> �...@property public Boolean ROLE_SUPER; > This only works in your page and component classes. You'll need to > create your own getter/setters. > > Josh > > On Wed, Jul 7, 2010 at 3:59 PM, ebt wrote: >> >> I have a class that I am using for each row in a grid, it is the mix of >> multiple entities data. the question is where to put it? I tried placing >> the >> class in the component package and instantiating it within my page, tried >> returning the class from an injected service, and nesting the class >> within >> the page POJO. in all cases it will work once and then on refresh I get >> this >> error: >> >> Failure writing parameter 'row' of component admin/Add:grid.rows: Failure >> writing parameter 'row' of component admin/Add:grid: Could not find a >> coercion from type com.foo.bar.pages.admin.Add$RolesRow to type >> com.foo.bar.pages.admin.Add$RolesRow. >> >> >> here is the class >> >> public static class RolesRow{ >> �...@property public Boolean ROLE_SUPER; >> �...@property public Boolean ROLE_ADMIN; >> �...@property public Boolean ROLE_USER; >> �...@property public Boolean ROLE_VIEW; >> �...@property public Boolean ROLE_EMAIL; >> private Map roles; >> public RolesRow(){ >> >> } >> public RolesRow(Map roles){ >> ROLE_SUPER = (roles.containsKey("ROLE_SUPER") ? true:false); >> ROLE_ADMIN = (roles.containsKey("ROLE_ADMIN") ? true:false); >> ROLE_USER = (roles.containsKey("ROLE_USER") ? true:false); >> ROLE_VIEW = (roles.containsKey("ROLE_VIEW") ? true:false); >> ROLE_EMAIL = (roles.containsKey("ROLE_EMAIL") ? true:false); >> this.roles = roles; >> } >> public List selected(){ >> List r = new ArrayList(); >> checked(r,"ROLE_SUPER",ROLE_SUPER); >> checked(r,"ROLE_ADMIN",ROLE_ADMIN); >> checked(r,"ROLE_USER",ROLE_USER); >> checked(r,"ROLE_VIEW",ROLE_VIEW); >> checked(r,"ROLE_EMAIL",ROLE_EMAIL); >> return r; >> } >> private void checked(List r,String field,Boolean obj){ >> if (obj !=null && obj == true){ >> r.add(roles.get(field)); >> } >> >> } >> I am instantiating the record in setupRender: >> >> void setupRender(){ >> List list = new ArrayList(); >> list.add(new RolesRow()); >> -- >> View this message in context: >> http://old.nabble.com/Where-to-define-this-class--tp2911p2911.html >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > > > -- > -- > http://www.bodylabgym.com - a private, by appointment only, one-on-one > health and fitness facility. > -- > http://www.ectransition.com - Quality Electronic Cigarettes at a > reasonable price! > -- > TheDailyTube.com. Sign up and get the best new videos on the internet > delivered fresh to your inbox. > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > -- View this message in context: http://old.nabble.com/Where-to-define-this-class--tp2911p29103188.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: javassist error with Tapestry 5.1.0.5 and JBoss 4.2.3GA
Changing javassist jar didn't work. I still receive the errors. By the way, the exception is thrown by "org.hibernate.tuple.entity.PojoEntityTuplizer". Is there a incompatibility with the hibernate jars? One more issue is that the logging level of the stack trace is in WARN level. And I still haven't encountered anything weird in runtime. On Thu, Jul 1, 2010 at 9:50 AM, Joachim Van der Auwera wrote: > I think you should update the javassist in jboss/server/default/lib/ > folder. > > Joachim > > > On 07/01/2010 08:08 AM, Halil Karakose wrote: > >> Hi, >> I receive an error in my Tapestry webapp. I use Tapestry 5.1.0.5 and Jboss >> 4.2.3-GA. >> >> >> *Scenario 1:* >> My web application contains javassist 3.9.0.GA in WEB-INF/lib folder. And >> there is also another javassist.jar(3.6.0.GA) file inside >> jboss/server/default/lib folder. >> >> During deployment of the web application, I receive such an exception: >> >> 22:12:28,373 WARN buildProxyFactory >> [org.hibernate.tuple.entity.PojoEntityTuplizer] could not create proxy >> factory for:com.mycompany.model.User >> org.hibernate.HibernateException: Javassist Enhancement failed: >> com.mycompany.model.User >> at >> >> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:145) >> at >> >> org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:42) >> at >> >> org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162) >> at >> >> org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135) >> at >> >> org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55) >> at >> >> org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56) >> at >> >> org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302) >> Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: >> Can not set static javassist.util.proxy.MethodFilter field >> com.mycompany.model.User_$$_javassist_5._method_filter to >> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer$1 >> at javassist.util.proxy.ProxyFactory.setField(ProxyFactory.java:356) >> at >> javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339) >> at >> javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:312) >> at >> javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:271) >> at >> >> org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:138) >> ... 171 more >> >> >> This error doesn't prevent deployment. And I have no idea what the impact >> of >> this error is or will be. I can select, and insert via webapp. >> >> >> *Scenario 2:* >> If I exclude javassist 3.9.0.GA from my Tapestry webapp and leave jboss's >> javassist.jar in place, the application deploys without exception. But, in >> this case, I encounter an exception in runtime: >> >> org.apache.tapestry5.internal.services.TransformationException: >> javassist.CannotCompileException: broken method >> >> InternalClassTransformation[ >> >> public com.mycompany.webapp.pages.PasswordHint extends >> com.mycompany.webapp.pages.BasePage >> >> >> >> add method: private void _$write_logger_2(org.slf4j.Logger $1) >> >> throw new java.lang.RuntimeException("Field >> com.mycompany.webapp.pages.PasswordHint.logger is read-only."); >> >> >> >> replace write logger: _$write_logger_2(); >> .. >> >> >> I am now following scenario 1, and I have not faced anything weird in >> runtime? Any suggestions are appreciated:), >> >> >> Thanks... >> >