Try this: 

             1.      Assume u have a textfield text1

             2      Write an ajax behavior as follows (for a link e.g)

               AjaxEventBehavior b1 = new AjaxEventBehavior("onclick"){

                        @Override
                        protected void onEvent(AjaxRequestTarget target) {
                                                
                         // Here access the web request for text1 
                        }
                        
                        /***
                        Modify the url to contain the text1 value
                        **/

                        @Override
                        public CharSequence getCallbackUrl() {
                                String otherInput =
"wicketSerialize(document.getElementById('"+text1.getMarkupId()+"'))";
                                return super.getCallbackUrl()+"',"+otherInput;
                        }
                        
                        protected CharSequence getCallbackScript(boolean 
recordPageVersion,
boolean onlyTargetActivePage)
                        {
                                return getCallbackScript("wicketAjaxPost('"
                                                + getCallbackUrl(), null, null);
                        }

                };


-swaroop



ywtsang wrote:
> 
> i have traced the wicket source codes at the place that how it generates
> the ajax js like
> wcall=wicketAjaxGet('xxx') 
> but i don't know exactly what this does, so how to "add parameter" to the
> wicket ajax request?
> 
> i can add custom js to the wicket ajax javascript, but how can I pass the
> some dynamic js state into that ajax request, e.g. i trigger the ajax
> request by a link with AjaxEventBehavior on onclick event.
> 
> would you mind show me a simple example?
> 
> 
> 
> 
> David Bernard-2 wrote:
>> 
>> For a similar case, I override (in MyBehavior)
>>      @Override
>>      public final void respond(AjaxRequestTarget target) {
>>          try {
>>              Request req = RequestCycle.get().getRequest();
>>              String param1 = req.getParameter("param1");
>>              // to stuff
>>              super.respond(target); //??
>>          } catch (RuntimeException exc) {
>>              throw exc;
>>          } catch (Exception exc) {
>>              throw new RuntimeException("wrap: " + exc.getMessage(),
>> exc);
>>          }
>>      }
>> 
>> And you need to override (server or client side) the callbackUrl to add
>> parameter.
>> 
>> 
>> 
>> ywtsang wrote:
>>> How to pass information (stored in an attribute of a html tag, or
>>> javascript
>>> variable) through ajax without involving form?
>>> 
>>> e.g. there is an ajax link and after I click this ajax link, an ajax
>>> event
>>> is triggered and I want to get the states of other html
>>> elements/javascript
>>> states in this ajax event
>>> 
>>> it is no problem to use form, but we have a restriction that no form is
>>> used
>>> (may look weird to all here), so I would like to see if there is
>>> workaround
>>> in wicket.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/pass-information-through-ajax-without-form-tf4560660.html#a13017394
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to