Monday 15 February 2010

ajax - How to combine a stateful browser creating tabular data with a Wicket web application? -


I am trying to write a wicket customer, which is something important. This gives me some headache because I have a form of presenting some accurate data. Every time every time a row is added / removed, Ajax should be able to add / delete rows in user data without provocation of the request. I have implemented the functionality of the ADR line in the browser which works perfectly using jQuery. The question is how do I work with this wicket?

My html snippet:

  & lt; Table class = "table" & gt; & Lt; Thead & gt; ... & lt; / Thead & gt; & Lt; Tbody & gt; & Lt; Tr wicket: id = "travel package" & gt; & Lt; Td> & Lt; Input Wit: id = "berth.name" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input Wit: id = "berth.position.lattitude" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input Wit: id = "berth.position.longitude" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input Wit: id = "arrival" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input Wit: id = "departure" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Button type = "submit" class = "btn btn-danger" & gt; Remove & lt; / Button & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;   

My Java code:

  Private Component Property Model & lt; List & lt; Travel & gt; & Gt; Model = new compound property model & lt; & Gt; (New voicemail ()); Public MyForm (String ID) {Super (ID, "MyForm"); WebMarkupContainer modalBody = New WebMarkupContainer ("modalBody", model); Adding (modalBody); Last Property List & lt; Travel & gt; Lv = new Property List View & Lt; Voyage & gt; ("Travel package") {@ Override protected void populatum (list system 
  • <> item.add (new textfield & lt; string & gt; ("key"); Item.add (new textfield & lt; string & gt; ("berth.name")); Item.add (new textfield & lt; string & gt; ("berth.position.lattitude"); Item.add (new textfield & lt; string & gt; ("berth.position.longitude")); Item.add (new textfield & lt; string & gt; ("arrival"); Item.add (new textfield & lt; string & gt; ("departure");}}; modalBody.add (lv); SaveLink = new AjaxSubmitLink ("save") {@Override protected void onSubmit (AjaxRequestTarget target, Lt ;? & gt; form) {shipService.saveVoyageInformation (model.getObject ()); target.add (this.getParent ());}}; add; saveLink;} public class voice modellable loadable wallet module & lt ; LIST & Lt; Voice & gt; & gt; {Override protected list & lt; travel & gt; load {} return to myService.getVoyage (MMSI);}}

    After getting the code, the problem becomes more special, How is the list example updated to add and submit new rows? Currently only the changes are made to the existing rows. New rows are never saved in the database

    I have described here The idea of ​​writing functionality to send data as Jason by following the approach is thought to be: If I understand correctly, then this would mean that input such as TextField.setRequired etc. The put fields are not valid. Is it correctly understood?

    I would like an approach closer to normal wicket web request handling, input validation, etc. With all the benefits Itemprop = "text">

    If I understand correctly, what you want is to create a dynamic form, "dynamic" which means that the structure of the form is defined and potentially change during the runtime. is.

    This can be done with really, but it is not easy with any server-side web framework because client-side representation is to be kept in sync with server-side Java components. JACO is sending JSON on the server, to some extent bypassing the facilities of the wicket, as you have already told, and you have to re-code some things that usually takes wickets for you. .

    As I have seen it, you have the following options:

    • You can code your own "dynamic form" component with the wicket, Which you have already started in your code snippet You will have to solve a lot of problems like you have already stumbled: How to update your wiki list component (maybe my blog post will help).

    • You can use a malformed form () which is a library which I am currently developing to create a dynamic form with a wicket. It has not been released yet, but you can use it at your own risk (or you can look at the sources and build your own) There is a showcase on the project homepage that shows the features. See if it meets your needs.

  • No comments:

    Post a Comment