I don't know how to get the postdata from the request object in wicket. I do
see the request being sent. As you see from the example I am struck there, I
don't know how to proceed further. 
This is just a basic example of round trip using Json, AJax and wicket
through form submit. You get the Json data modify it update back the form.
There will be more complicated of this like grid update.
Also there can be normal form submit of Json object. In either case I don't
know how to handle on the server in wicket. I have done lot using JSP, it
looks bit different here. And no good documentation.
If you can provide some coding example or some pointer it would be great.

~Pen





Johan Compagner wrote:
> 
> Which part goes wrong?
> Do you see the request being send?
> Why do this though json? If you need json objects on the server why
> not using  a normal form post and create the json object on the
> server?
> 
> 2007/11/24, Pen <[EMAIL PROTECTED]>:
>>
>> Greetings,
>>
>> I want to know how to handle the Jquery, JSon data in the wicket. What is
>> the best way to do it.
>> I have created simple form which sends the json data across to server and
>> replies back to the form.
>> I am not sure how to handle the request and response in wicket. I am
>> using
>> Json-lib 2.1 for jdk1.5
>> Can anybody analyze the below program and suggest me what is wrong.
>>
>> demo.html
>> <head>
>>      <script src="scripts/jquery-1.2.1.js" type="text/javascript"
>> charset="utf-8"></script>    
>>      <script type="text/javascript" charset="utf-8">
>>              $(document).ready(function() {
>>                      $("#testForm").submit(sendForm);
>>              });
>>              
>>              function sendForm(e) {
>>                      e.preventDefault();
>>                      var data = {
>>                              field1: $("#field1").val(),
>>                              field2: $("#field2").val(),
>>                              field3: $("#field3").val(),
>>                      };
>>                      
>>                      $("#sent .content").html(data.toSource());
>>                      $.post("demo", "message=[" + data.toSource() + "];", 
>> receiveForm,
>> "json");
>>              };              
>>      
>>               function receiveForm(data) {
>>                      $("#field1").val(data.field1);
>>                      $("#field2").val(data.field2);
>>                      $("#field3").val(data.field3);
>>                      
>>                      $("#received .content").html(data.toSource());
>>              };
>>      </script>
>>      
>> </head>
>> <body>
>>
>> <form wicket:id="testForm"  >
>>      <h1 id="form">Form</h1>
>>      
>>      <label for="field1">Field One:</label>
>>      <input type="text" id="field1" />
>>      
>>      <label for="field2">Field Two:</label>
>>      <input type="text" id="field2" />
>>      
>>      <label for="field3">Field Three:</label>
>>      <input type="text" id="field3" />
>>      
>>      <input type="submit" id="submitter" value="Post the data" />
>> </form>
>>
>> <div id="sent" class="readout">
>>      <h1 id="sent_data:">Sent Data:</h1>
>>      <div class="content">
>>              
>>      </div>
>> </div>
>> <div id="received" class="readout">
>>
>>      <h1 id="received_data">Received Data:</h1>
>>      <div class="content">
>>              
>>      </div>
>> </div>
>> </body>
>> </html>
>>
>> Here is the wicket program to handle this
>>
>> demo.java
>> public class Demo extends BasePage {
>>      public Demo() {
>>              
>>              Form form = new Form("testForm",new 
>> CompoundPropertyModel(this));
>>              add(form);
>>              form.add(new AjaxFormSubmitBehavior(form,"onsubmit"){
>>                      private static final long serialVersionUID = 1L;        
>>                 
>>
>>                      protected void onSubmit(AjaxRequestTarget target) {
>>                              Request request = getRequest();
>>                              String data = request.getParameter("data");     
>>                 
>>                              try {
>>                                      JSONObject jsonData = new JSONObject();
>>                                      JSONObject selectedNode = 
>> jsonData.getJSONObject(data);                                 
>>                              } catch (Exception e) {
>>                                      throw new RuntimeException("Failed to 
>> parse selected node from
>> reply: "
>> + data);
>>                              }
>>                              //target.addComponent(received)// Add to the 
>> response data
>>                      }
>>              });
>>      }
>> }
>>
>>
>> ~Pen
>> --
>> View this message in context:
>> http://www.nabble.com/howto-JSON-Wicket-works--tf4865188.html#a13922782
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/howto-JSON-Wicket-works--tf4865188.html#a13928701
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