You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by armandoxxx <ar...@dropchop.com> on 2014/10/22 19:51:03 UTC
Wicket.Ajax.post array parameters
Hey guys
need a little help with sending array parameter value with Wicket.Ajax.post
(wicket 6.x)...
any help appreciated
regards
Armando
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-post-array-parameters-tp4668041.html
Sent from the Users forum 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.post array parameters
Posted by Roland Dobsai <ro...@gmail.com>.
public abstract class SortableBehavior extends AbstractDefaultAjaxBehavior
{
@Override
protected void respond(AjaxRequestTarget target)
{
StringValue prevValue =
RequestCycle.get().getRequest().getRequestParameters().getParameterValue("prev");
StringValue draggedrValue =
RequestCycle.get().getRequest().getRequestParameters().getParameterValue("dragged");
StringValue nextValue =
RequestCycle.get().getRequest().getRequestParameters().getParameterValue("next");
update(target, parseIndex(prevValue), parseIndex(draggedrValue),
parseIndex(nextValue));
}
protected abstract void update(AjaxRequestTarget target, Long prev,
Long dragged, Long next);
protected Long parseIndex(StringValue sv) {
if (sv.isEmpty() || sv.isNull() ||
!sv.toString().matches("[0-9]+")) {
return null;
} else {
return sv.toLongObject();
}
}
@Override
public void renderHead(Component component, IHeaderResponse response)
{
StringBuilder js = new StringBuilder();
js.append("$(function() {");
js.append(" $( '#"+component.getMarkupId()+" ul' ).sortable( {");
js.append(" update: function( event, ui ) {");
js.append(" var dragged = ui.item.attr('id');");
js.append(" var prev = ui.item.prev().attr( 'id' );");
js.append(" var next = ui.item.next().attr( 'id' );");
js.append(" var callBackUrl = '"+getCallbackUrl()+"';");
js.append(" Wicket.Ajax.ajax({ u: callBackUrl, ep: {prev:
prev, dragged: dragged, next: next}});");
js.append(" }");
js.append(" });");
js.append(" $( '#"+component.getMarkupId()+" ul'
).disableSelection();");
js.append("});");
response.render(OnDomReadyHeaderItem.forScript(js));
super.renderHead(component, response);
}
here is a complete example with post exactly the same only you acces the
parameters with a like that:
StringValue parameterValue =
RequestCycle.get().getRequest().getPostParameters().getParameterValue("text");
I hope that's what you wanted
2014-10-22 18:51 GMT+01:00 armandoxxx <ar...@dropchop.com>:
> Hey guys
>
> need a little help with sending array parameter value with Wicket.Ajax.post
> (wicket 6.x)...
>
>
>
> any help appreciated
>
> regards
>
> Armando
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Ajax-post-array-parameters-tp4668041.html
> Sent from the Users forum 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
>
>