Re: Custom AJAX component...
Erik, Its been a while since I implemented that code but as far as I remember the CDATA parts are embedded in a bigger XML wich is streamed back to the client: CDATA is needed because grid cell contents can be anything so you have to use it to make sure that the XML you stream back is well formed. The sequence of event is as follows. -GRID is build on the client and client issues a jQuere AJAX call to the sever (to the URL generated using the AJAX behavior) -GRID component generates the XML on the server side and this XML is streamed back to client -Client uses this data to render grid cell contents. That's all about it;-) Can you describe more precisely what you want to achieve? Cheers, Ernesto On Wed, Aug 18, 2010 at 11:12 PM, Erik Brakkee erik.brak...@gmail.com wrote: I have been looking at the example from jqgrid and as far as I can understand the resource listener is used to stream back the XML content as CDATA from the server to the browser. However, I cannot see how it would be possible to stream back XML from the browser to the server. One way I can imagine it would work is by creating a form (with CSS style display none) which has a form text field with a value). In that case, submitting the form will also submit the text field and it becomes possible to both read the XML from the custom text field and rerender other wicket components as part of the same request (and also use prepend and/or append javascript). Am I missing something? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
Hi Ernesto, The approach you suggest does fit my needs, especially if I can send XML content from the browser to the server. I am exploring possibilities and one of those is using wicketAjaxPost(). The other one is the jqgrid approach which might be more flexible. I cannot quite understand how it works. It looks like the key is the GridXMLData component and the DocumentListener but I don't see yet how you use those to get the XML data back to the server. Cheers Erik On Tue, Aug 17, 2010 at 10:42 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: 1-use the behavior to generate a URL. 2-use that URL on client side to call the behavior 3-use the behavior to produce the content you want to stream (XML). 4-do what ever you want with that contents. That's more or less what the jqgrid example does. Does that approach fit your use case? Ernesto On Tue, Aug 17, 2010 at 10:07 PM, Erik Brakkee erik.brak...@gmail.com wrote: Thanks to wicket's clean code I am a bit further now. It looks like it is possible to add custom javascript to be executed just before and after rendering the components. This can be done using AjaxRequestTarget.append/prependJavascript(). So in other words, using this method it is possible to pass data (even behavior) back to the client. It is still not clear to me how it would be possible to pass additional data from the web browser to the server in the AbstractDefaultAjaxBehavior and then read it in the respond() method of the behavior. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
I have been looking at the example from jqgrid and as far as I can understand the resource listener is used to stream back the XML content as CDATA from the server to the browser. However, I cannot see how it would be possible to stream back XML from the browser to the server. One way I can imagine it would work is by creating a form (with CSS style display none) which has a form text field with a value). In that case, submitting the form will also submit the text field and it becomes possible to both read the XML from the custom text field and rerender other wicket components as part of the same request (and also use prepend and/or append javascript). Am I missing something?
Re: Custom AJAX component...
On Tue, Aug 17, 2010 at 7:02 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: In case of wiQuery, many behaviors wicket AJAX is used (not jquery AJAX) so it seem natural to use AbstractDefaultAjaxBehavior. In other cases probably you are right and it is over killing. Is that what you are asking? Well I imagine it is nice to be able to combine a custom framework using wicket ajax as that would probably allow someone to perform the custom AJAX behavior together with rendering wicketcomponents when the behavior is triggered. I am just trying to understand how this works. Right now I understand the simple method of AbstractAjaxBehavior.] I am now just wondering how the approach using wicket ajax works. Is there documentation explaining how to hook in custom client side behavior using wicket ajax. In other words, re-rendering wicket components AND reading a custom payload from the message, and returning a custom payload to be processed by the custom javascript. Both the wicket XML request and response must carry somehow the other information transparently. In the AutocompletBehavior of wiquery they are just getting the response and writing directly to it, ignoring the request target, whereas as I understand it now the request target is the interface towards the response so bypassing it is risky.
Re: Custom AJAX component...
Thanks to wicket's clean code I am a bit further now. It looks like it is possible to add custom javascript to be executed just before and after rendering the components. This can be done using AjaxRequestTarget.append/prependJavascript(). So in other words, using this method it is possible to pass data (even behavior) back to the client. It is still not clear to me how it would be possible to pass additional data from the web browser to the server in the AbstractDefaultAjaxBehavior and then read it in the respond() method of the behavior.
Re: Custom AJAX component...
1-use the behavior to generate a URL. 2-use that URL on client side to call the behavior 3-use the behavior to produce the content you want to stream (XML). 4-do what ever you want with that contents. That's more or less what the jqgrid example does. Does that approach fit your use case? Ernesto On Tue, Aug 17, 2010 at 10:07 PM, Erik Brakkee erik.brak...@gmail.com wrote: Thanks to wicket's clean code I am a bit further now. It looks like it is possible to add custom javascript to be executed just before and after rendering the components. This can be done using AjaxRequestTarget.append/prependJavascript(). So in other words, using this method it is possible to pass data (even behavior) back to the client. It is still not clear to me how it would be possible to pass additional data from the web browser to the server in the AbstractDefaultAjaxBehavior and then read it in the respond() method of the behavior. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
I have found this page https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html which talks about wicketAjaxGet() and wicketAjaxPost(), but again no mention of how to access the body that is sent using wicketAjaxPost(). Only request parameters are discussed. Is accessing the body simply a matter of using the basic HttpServletRequest APIs? Cheers Erik
Re: Custom AJAX component...
I have seen that wiquery for instance takes another approach in for instance their AutoCompleteBehavior. In that class they override respond() and get the response from the requestcycle and start writing to it, like this: @Override protected void respond(AjaxRequestTarget target) { // response: outputing the list of results as a js map ListAutocompleteValueT, E results = autocomplete(); Response response = this.getComponent().getRequestCycle().getResponse(); response.write({); for (AutocompleteValueT, E autocompleteValue : results) { autocompleteValue.write(response); } response.write(}); } If this is the correct approach it would be nice because it would allow me to have complete control over generating the response. But, is this a valid approach? Will it not interfere with the default response? Or is everything ok as along as no components are added to the request target? Can anyone comment on the validity of this approach? If this is not a recommended approach then what is the correct approach to take for getting complete control over the response content from an ajax behavior? Cheers Erik
Re: Custom AJAX component...
I have been looking around a bit more and it seems like Wicket in Action provides a solution on p.260 (the book keeps on growing on me). It looks like the idea is to extend AbstractAjaxBehavior and use RequestCycle.get().setRequestTarget(new StringRequestTarget(myString)); or more generically use ResourceStreamRequestTarget. From the looks of it, the wicket-specific ajax library comes in through AbstractDefautAjaxBehavior. It beats me why some libraries are still extending AbstractDefaultAjaxBehavior if they are integrating a custom framework. Cheers Erik
Re: Custom AJAX component...
In case of wiQuery, many behaviors wicket AJAX is used (not jquery AJAX) so it seem natural to use AbstractDefaultAjaxBehavior. In other cases probably you are right and it is over killing. Is that what you are asking? Cheers, Ernesto On Mon, Aug 16, 2010 at 10:47 PM, Erik Brakkee erik.brak...@gmail.com wrote: I have been looking around a bit more and it seems like Wicket in Action provides a solution on p.260 (the book keeps on growing on me). It looks like the idea is to extend AbstractAjaxBehavior and use RequestCycle.get().setRequestTarget(new StringRequestTarget(myString)); or more generically use ResourceStreamRequestTarget. From the looks of it, the wicket-specific ajax library comes in through AbstractDefautAjaxBehavior. It beats me why some libraries are still extending AbstractDefaultAjaxBehavior if they are integrating a custom framework. Cheers Erik - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
Erik, Grid component [1] does something similar to what you are asking for: -Grid is created via JavaScript -Grid ask back to server for some XML containing the data to render and generate the grids contents. The trick I use to render XML back to the server is creating a div that will stream back the contents as XML. See classes [1] and [2] for details. Regards, Ernesto References. 1-http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/Grid.java 2-http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/DocumentResourceListener.java On Sat, Aug 14, 2010 at 10:59 PM, Erik Brakkee erik.brak...@gmail.com wrote: Hi, I would like to write an component that will retrieve page-specific information using AJAX from the javascript running in the browser and interpret it itself instead of having wicket rendering the content. This approach is slightly different from the usual behavior as in those cases a wicket component renders its own content again and the page is updated with the new content of the component. In this case however, I would like to return an XML document which is interpreted by the javascript directly, where the XML document is page specific. How can I achieve such a scenario? Any examples somewhere? Is there a specific Component type or behavior I should use? Cheers Erik - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
and you can see the grid at work here http://wiquery-plugins-demo.appspot.com/demo/?wicket:bookmarkablePage=:com.wiquery.plugins.demo.GridPage Ernesto On Sun, Aug 15, 2010 at 8:07 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Erik, Grid component [1] does something similar to what you are asking for: -Grid is created via JavaScript -Grid ask back to server for some XML containing the data to render and generate the grids contents. The trick I use to render XML back to the server is creating a div that will stream back the contents as XML. See classes [1] and [2] for details. Regards, Ernesto References. 1-http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/Grid.java 2-http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/DocumentResourceListener.java On Sat, Aug 14, 2010 at 10:59 PM, Erik Brakkee erik.brak...@gmail.com wrote: Hi, I would like to write an component that will retrieve page-specific information using AJAX from the javascript running in the browser and interpret it itself instead of having wicket rendering the content. This approach is slightly different from the usual behavior as in those cases a wicket component renders its own content again and the page is updated with the new content of the component. In this case however, I would like to return an XML document which is interpreted by the javascript directly, where the XML document is page specific. How can I achieve such a scenario? Any examples somewhere? Is there a specific Component type or behavior I should use? Cheers Erik - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Custom AJAX component...
Thanks very much for the examples, I will have a look at them. On Sun, Aug 15, 2010 at 8:09 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: and you can see the grid at work here http://wiquery-plugins-demo.appspot.com/demo/?wicket:bookmarkablePage=:com.wiquery.plugins.demo.GridPage Ernesto On Sun, Aug 15, 2010 at 8:07 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Erik, Grid component [1] does something similar to what you are asking for: -Grid is created via JavaScript -Grid ask back to server for some XML containing the data to render and generate the grids contents. The trick I use to render XML back to the server is creating a div that will stream back the contents as XML. See classes [1] and [2] for details. Regards, Ernesto References. 1- http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/Grid.java 2- http://code.google.com/p/wiquery-plugins/source/browse/trunk/wiquery-plugins/jqgrid/src/main/java/com/wiquery/plugins/jqgrid/component/DocumentResourceListener.java On Sat, Aug 14, 2010 at 10:59 PM, Erik Brakkee erik.brak...@gmail.com wrote: Hi, I would like to write an component that will retrieve page-specific information using AJAX from the javascript running in the browser and interpret it itself instead of having wicket rendering the content. This approach is slightly different from the usual behavior as in those cases a wicket component renders its own content again and the page is updated with the new content of the component. In this case however, I would like to return an XML document which is interpreted by the javascript directly, where the XML document is page specific. How can I achieve such a scenario? Any examples somewhere? Is there a specific Component type or behavior I should use? Cheers Erik - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Custom AJAX component...
Hi, I would like to write an component that will retrieve page-specific information using AJAX from the javascript running in the browser and interpret it itself instead of having wicket rendering the content. This approach is slightly different from the usual behavior as in those cases a wicket component renders its own content again and the page is updated with the new content of the component. In this case however, I would like to return an XML document which is interpreted by the javascript directly, where the XML document is page specific. How can I achieve such a scenario? Any examples somewhere? Is there a specific Component type or behavior I should use? Cheers Erik
Re: Custom AJAX component...
in wicket-examples there is a demo that integrates prototype ajax into wicket, see if that is doing what you want. -igor On Sat, Aug 14, 2010 at 1:59 PM, Erik Brakkee erik.brak...@gmail.com wrote: Hi, I would like to write an component that will retrieve page-specific information using AJAX from the javascript running in the browser and interpret it itself instead of having wicket rendering the content. This approach is slightly different from the usual behavior as in those cases a wicket component renders its own content again and the page is updated with the new content of the component. In this case however, I would like to return an XML document which is interpreted by the javascript directly, where the XML document is page specific. How can I achieve such a scenario? Any examples somewhere? Is there a specific Component type or behavior I should use? Cheers Erik - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org