That's cool.

I'm still surprised to see that whenever something remotely
ressembling stateless/REST comes up in the mailing list, the gut
reaction is: servlets. It might be simpler for a few usecases, but
normally you also want to take advantage of other Wicket features -
precisely the reason why Serban insists with the Ajax behaviour.

If it is feasible already, what I really would like is to have better
support for doing REST. Of course you don't want to "drive screw into
a board with a hammer" but for many cases simple stateless suffices,
where Jersey would be an overkill and servlets out of the picture.
Those usecases include sites where you want to expose some
functionality as stateless (including Ajax) and the rest are heavily
interactive pages (like an admin or wizards) where Wicket excels.

I just recall the interest there was when the creator of
http://www.fitcomplex.sk/ mentioned what he was doing with jQuery.

Just a general feeling I'm expressing here.

Thanks,

Francisco



2009/7/31 richardwilko <richardjohnwilkin...@gmail.com>:
>
> Hi,
>
> Instead of using AbstractDefaultAjaxBehavior you can use its superclass
> AbstractAjaxBehavior as follows:
>
>        AbstractAjaxBehavior behaviour = new AbstractAjaxBehavior()
>        {
>            private static final long serialVersionUID = 1L;
>
>           �...@suppresswarnings("unchecked")
>            public void onRequest()
>            {
>                //get parameters
>                final RequestCycle requestCycle = RequestCycle.get();
>
>                final PageParameters pageParameters = new
> PageParameters(requestCycle.getRequest().getParameterMap());
>
>                //do something using nice json library to produce a string
> of json
>                String json = .......
>
>
>                requestCycle.setRequestTarget(new
> StringRequestTarget("application/json", "utf-8", data));
>            }
>
>        };
>        add(behaviour);
>
> I can't see anything wrong with the servlet example, but this has the
> advantage of being in a Wicket component, so you can easily access your
> Wicket session, and the user wont have to remember to map extra servlets.
>
> I have also tried making a component out of flexigrid, but ran into issues
> (which they may have fixed now), for example, I was getting rendering issues
> in the grid when trying to resize the columns.
>
> I then moved onto another jQuery grid called jqGrid
> (http://www.trirand.com/blog/) which I felt had more features and was more
> robust.
>
> At jWeekend (http://www.jweekend.com) have almost completed the Wicket
> mapping of this grid and we hope to release this in the future when we are
> satisfied with our testing and API.  This will be released as a plugin to
> the wiQuery project (http://code.google.com/p/wiquery/), which basically
> means it will depend on wiQuery.
>
>
> Regards - Richard Wilkinson
> Developer
> jWeekend: OO & Java Technologies - Development and Training
> http://jWeekend.com
>
>
>
>
>
>
> Serban Balamaci wrote:
>>
>> Hello. I'm trying to create a wicket component out of FlexiGrid
>> http://www.flexigrid.info/ .
>>
>> The javascript for the component requires an address from which it will
>> receive data in the form of a JSON response.
>>
>>
>>
>> I'm not sure what is the best way to go about it. Simple and most ugly
>> approach would be to have something of a "Controller Page"
>>
>> a page that takes parameters such as the entity that is being retrieved
>> and
>> also paging info, sort order, etc and returns the JSON response.
>>
>> I do not like this aproach as, most obvious reason is that it would not be
>> obvious from the component what you need to do in order to get it to work.
>>
>>
>>
>> I would much more preffer to having a callback method that returns the
>> json.
>> So I have created a
>>
>>
>>
>> AbstractDefaultAjaxBehavior clientConnectBehavior = new
>> AbstractDefaultAjaxBehavior() {
>>
>>
>>
>>             protected void respond(AjaxRequestTarget ajaxRequestTarget) {
>>
>>                    ajaxRequestTarget.prependJavascript("{page: 1, total:
>> 239
>> }");
>>
>>
>>
>>             }
>>
>> and used clientConnectBehavior.getCallbackUrl() as the url passed to the
>> flexigrid.
>>
>>
>>
>> Unfortunately the problem is the response when invoked is wrapped in a
>> <ajax-response><evaluate encoding="wicket1">
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <ajax-response><evaluate encoding="wicket1"><![CDATA[{page: 1,total:
>> 239}]]></evaluate></ajax-response>
>>
>>
>>
>> So my question is how to get only the JSON part without the <?xml
>> version.>,
>> <ajax-response> . and <CDATA> decoration. Can it be bypassed? Shoul I
>> override something in AbstractDefaultAjaxBehavior?
>>
>> Or any other ideea to go about the problem.
>>
>>
>>
>> Thank you,
>>
>>
>>
>> Serban
>>
>>
>>
>
>
> -----
> http://richard-wilkinson.co.uk My blog: http://richard-wilkinson.co.uk
> --
> View this message in context: 
> http://www.nabble.com/Wicket%2C-Ajax-and-JSON-tp24756591p24757846.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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

Reply via email to