Wicket : Submitting data with a listview inside a form -
I have the following problems:
Imagine a track list view, which looks something like this:
List View & lt; Question & gt; LvQuestion = New ListView & lt; Question & gt; ("LV Question", question) {Personal Static last long serial VERSIONUID = 1L; @ Override Protected Zero Populated Entom (ListInstream Item) {Query q = item.getModelObject (); Item.add (new label ("question", q.get question ())); & Lt; String & gt; Possible answer = getFromDb (); Q.setPossibleAnswers (possibleAnswers); If (q.getComponent (.) Equals ("dropdown") {item.add (new dropdownPanel ("questionability", Q)); }}}; This list view is built within a form component; What I need to do is to answer each question using this list visit and they are recorded in the database.
However, the problem is that I do not know how many will drop down the table to me because always there will
It is a way of ensuring that when submitting the form to parents , Then each model is submitted in the list view.
I created with the chosen option for what I will question every Harmap these situations keeps. I update it with updates like AjaxFormComponentUpdatingBehavior: First, declare & amp; Initializing the map (can be a more efficient way of doing this)
Maps & lt; Question, String & gt; QMap = new hashmap & lt; & Gt; (); (Question question: question) {qMap.put (q, ""); } Then, update map within your ListView (you probably cue you want to set the final when you start it)
< code> if (q.getComponent () .akwayls ( "drop down")) {Dropdaunpanel DDP = new Dropdaunpanel ( "Prsnsngtta", Q); Ddpkadd (New AjaxFormComponentUpdatingBehavior ( "onchange") {@Override (AjaxRequestTarget Art) {String response = (string) GetFormComponent () protected GetConvertedInput (zero onUpdate) ;. qMap.put (Q, response);}} item.add (DDP);.} This allows you to keep the qMap date and this process when the form is submitted
Alternatively, a String attribute if you have the answer to the question object and to make sure that your ListView.list and your list questions consistently To make the living, you can do the following in the updating (without the need of the map):
q SetAnswer (answer); question .set (item.getIndex (), q); In this case, you will only process the form on the ONIMIT () form on the question list.
Comments
Post a Comment