You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by MattyDE <uf...@gmail.com> on 2010/06/11 12:39:18 UTC

Wicket Ajax Event on Component with Parameters

Hi Folks,

i want to add an "custom" Event "filter" to an HTML-Component. So that
another plugin/function or something else, on client-side could call this
event and transfer some parameters (by ajax-post) to wicket on server-side.

Any Ideas for this?

I Tried with 

                gridView.add(new
WiQueryAjaxEventBehavior(FilterEvent.FILTER) {
			
			@Override
			protected void onEvent(AjaxRequestTarget target) {
			    Request request = RequestCycle.get().getRequest();
			    String[] params = request.getParameters("ids");
			    //params is every time empty
			}
		});

this generates a

 $('#grid__view5').bind('filter', function() {
48 var
wcall=wicketAjaxGet('?wicket:interface=:1:table_watchlist:grid_view::IBehaviorListener:2:',null,null,
function() {return true}.bind(this));
49}); 

in my markup.

And it works, except for not transfering any parameters if i call
"$(#componentId).trigger("filter")"

Thanks in Advance for Help!
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251592.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Martin Grigorov <mc...@e-card.bg>.
On Fri, 2010-06-18 at 08:01 -0700, MattyDE wrote:
> Hi Jeremy,
> 
> Thanks for your reply. It looks like what i've looking for. But i need this
> with POST not with GET. Cause the GET-URL is to limited to internet
> standards and i have to transfer a bunch of more data back to the
> server-side.
> 
> Any hint for POST?
Instead of wicketAjaxGet() use wicketAjaxPost().
See how to pass the parameters in wicket-ajax.js
> 
> Thanks



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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
Hi Jeremy,

Thanks for your reply. It looks like what i've looking for. But i need this
with POST not with GET. Cause the GET-URL is to limited to internet
standards and i have to transfer a bunch of more data back to the
server-side.

Any hint for POST?

Thanks
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2260352.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Fri, Jun 18, 2010 at 3:21 AM, MattyDE <uf...@gmail.com> wrote:

>
> Igoooooor... i need your help please :)
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2259861.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
instead of using wiquery event behavior, use your own and generate the
binding yourself:

new AbstractDefaultAjaxBehavior() {
  CharSequence getCallbackScript(boolean onlyTargetActivePage) {
    return "$('#" + getComponent().getMarkupId() + "').bind('filter',
function() { " +
    "wicketAjaxGet('" + getCallbackUrl(onlyTargetActivePage) + "&myIDs=' +
getSelectedIDs() + );}";
  }
}

notice that the getSelectedIDs() is a JS function that you would need to
define....  Fix the syntax (I probably have typos) and apply it to your use
case.


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
Igoooooor... i need your help please :)
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2259861.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
Sure i could.

But there are more and more complex Parameters as they could be added to an
URL ... so i need to Ajax-POST them, instead of GET .. this is my Problem.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2253965.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi Martin,

Can you just read the options "[1,12,355]" on the body of the function
you defined and append them to the URL?

Ernesto

On Mon, Jun 14, 2010 at 8:07 AM, MattyDE <uf...@gmail.com> wrote:
>
> No solution in sight yet =/
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2253954.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
No solution in sight yet =/
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2253954.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
No the Grid Component doesnt know this.... or want to know this on
client-side.

Is it not possible just to implement a method, which could be called by :

$("#gridview").trigger("filter", { 'ids': [1,12,355]});


totally from outside?

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251695.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Then the grid component should know what to send to the server side;-)
That's completely similar to the example I showed with AJAX slider
(slider sends positions to server side). Your grid will have to
iterate over the rows "state" (on client side) put that information
into a parameter and send it to the server side (and on the server
side do whatever you deem necessary  with that information).

Best,

Ernesto

On Fri, Jun 11, 2010 at 1:41 PM, MattyDE <uf...@gmail.com> wrote:
>
> And how could i do this?
>
> I dont want to reload the grid or anything. I just want to KNOW whats
> "happen" on client-side... in some scenarios...
>
> in My Example:
>
> the user filters the grid totally client-side. But the Filter-Plugin should
> tell my gridview-Component WHICH lines are still visible (ID-List)...
>
> Any hints?
>
> Thanks!
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251674.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
And how could i do this?

I dont want to reload the grid or anything. I just want to KNOW whats
"happen" on client-side... in some scenarios...

in My Example:

the user filters the grid totally client-side. But the Filter-Plugin should
tell my gridview-Component WHICH lines are still visible (ID-List)...

Any hints? 

Thanks!
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251674.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

Why not use Wicket standard AJAX submit machinery instead? And have
the grid rebuild itself after AJAX submit?

Ernesto

On Fri, Jun 11, 2010 at 1:20 PM, MattyDE <uf...@gmail.com> wrote:
>
> Okay, i'll try to explain what i want/have to do, with my noob-english ;)
>
> I've written my own gridview component for a big web-application.
> And some-one else who is responsible for the client-side thing, want to tell
> my gridview "hey yo, filter this values i submit to you!".
>
> So i thought, implementing a "Event" which could be called by anonther would
> be the best id.
>
> He want to deliver a json-array to my server-side implementation... how
> should i offer this interface?
>
> Thanks!
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251637.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
Okay, i'll try to explain what i want/have to do, with my noob-english ;)

I've written my own gridview component for a big web-application.
And some-one else who is responsible for the client-side thing, want to tell
my gridview "hey yo, filter this values i submit to you!".

So i thought, implementing a "Event" which could be called by anonther would
be the best id.

He want to deliver a json-array to my server-side implementation... how
should i offer this interface?

Thanks!
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251637.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

On Fri, Jun 11, 2010 at 12:59 PM, MattyDE <uf...@gmail.com> wrote:
>
> How should i do this from a client-side call? I dont know with Parameter will
> be submited from there.
>

Doesn't your component knows what to transfer? I really do not
understand what you want to try to achieve... I have used a similar
approach to transfer client side state to the server side e.g.

new StringBuffer()
					.append("var values = $(this).slider('values');")
					.append("var url = '").append(slider.sliderContext.getCallbackUrl(true))
					.append("&").append(SLIDER_EVENT).append("=").append(event.name())
					.append("&").append(SLIDER_VALUE).append("=").append("'+").append(Slider.UI_VALUE)
					.append("+'&").append(SLIDER_VALUES).append("=").append("'+").append("values")
					.append(";")					
					.append("wicketAjaxGet(url, null,null, function() {return
true;})").toString());

For an AJAX slider to handle slider events on the server side.

> strictly speaking i want do transfer a json Object to server-side through
> the Event Call.

Build the JSON object using some client logic? E.g. if you want to
submit a form iterate over fields and compose a JSON out of it. Again
I can't see what you want to achieve.

Regards,

Ernesto

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


Re: Wicket Ajax Event on Component with Parameters

Posted by MattyDE <uf...@gmail.com>.
How should i do this from a client-side call? I dont know with Parameter will
be submited from there.

strictly speaking i want do transfer a json Object to server-side through
the Event Call.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251610.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Wicket Ajax Event on Component with Parameters

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
append the parameter to the URL? Just try url+"&ids=test" and see if you get it.

Ernesto

On Fri, Jun 11, 2010 at 12:39 PM, MattyDE <uf...@gmail.com> wrote:
>
> Hi Folks,
>
> i want to add an "custom" Event "filter" to an HTML-Component. So that
> another plugin/function or something else, on client-side could call this
> event and transfer some parameters (by ajax-post) to wicket on server-side.
>
> Any Ideas for this?
>
> I Tried with
>
>                gridView.add(new
> WiQueryAjaxEventBehavior(FilterEvent.FILTER) {
>
>                        @Override
>                        protected void onEvent(AjaxRequestTarget target) {
>                            Request request = RequestCycle.get().getRequest();
>                            String[] params = request.getParameters("ids");
>                            //params is every time empty
>                        }
>                });
>
> this generates a
>
>  $('#grid__view5').bind('filter', function() {
> 48 var
> wcall=wicketAjaxGet('?wicket:interface=:1:table_watchlist:grid_view::IBehaviorListener:2:',null,null,
> function() {return true}.bind(this));
> 49});
>
> in my markup.
>
> And it works, except for not transfering any parameters if i call
> "$(#componentId).trigger("filter")"
>
> Thanks in Advance for Help!
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-Event-on-Component-with-Parameters-tp2251592p2251592.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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