Hi ,I am creating AjaxFallbackButton to dynamically add new instance to
collect data in PropertyListView.

however ,after it is saved in the xml , the new instance is add to every
child list.

screenshot like this 
this is the table of the PropertyListView  under income 1
<http://apache-wicket.1842946.n4.nabble.com/file/n4678402/2017-08-02_17_39_18-Los_Angeles_Department_of_Public_Social_Services_YourBenefitsNow.png>
 

this is the table of the PropertyListView under income 2
<http://apache-wicket.1842946.n4.nabble.com/file/n4678402/2017-08-02_17_41_42-Los_Angeles_Department_of_Public_Social_Services_YourBenefitsNow.png>
 

after saved, 
both of the PropertyListView has new instance.
<http://apache-wicket.1842946.n4.nabble.com/file/n4678402/2017-08-02_17_42_46-Los_Angeles_Department_of_Public_Social_Services_YourBenefitsNow.png>
 
<http://apache-wicket.1842946.n4.nabble.com/file/n4678402/2017-08-02_17_43_11-Los_Angeles_Department_of_Public_Social_Services_YourBenefitsNow.png>
 

the xml after saving is like below ,here the instance is added twice in each
one.

<ns4:section3>
      <ns4:incomes>
         <ns4:name>John, Taylor</ns4:name>
         <ns4:monthlyIncome>5000</ns4:monthlyIncome>
         <ns4:additionalIncome>
            <ns4:source>ddddd</ns4:source>
            <ns4:amount>1111</ns4:amount>
            <ns4:frequency>Monthly</ns4:frequency>
         </ns4:additionalIncome>
         <ns4:additionalIncome>
            <ns4:source>eeee</ns4:source>
            <ns4:amount>2222</ns4:amount>
            <ns4:frequency>Monthly</ns4:frequency>
         </ns4:additionalIncome>
         <ns4:lastYearIncome>2000</ns4:lastYearIncome>
      </ns4:incomes>
      <ns4:incomes>
         <ns4:name>Mary, Taylor</ns4:name>
         <ns4:monthlyIncome>5000</ns4:monthlyIncome>
         <ns4:additionalIncome>
            <ns4:source>ddddd</ns4:source>
            <ns4:amount>1111</ns4:amount>
            <ns4:frequency>Monthly</ns4:frequency>
         </ns4:additionalIncome>
         <ns4:additionalIncome>
            <ns4:source>eeee</ns4:source>
            <ns4:amount>2222</ns4:amount>
            <ns4:frequency>Monthly</ns4:frequency>
         </ns4:additionalIncome>
         <ns4:lastYearIncome>2000</ns4:lastYearIncome>
         <ns4:currentYearIncome>3000</ns4:currentYearIncome>       
      </ns4:incomes>
   </ns4:section3>

below is the code of the ajaxbutton

public Button getPartialRefreshAddButtonByListSize(String id, final int
size) {
                return new AjaxFallbackButton(id, null) {

                        /** Default serial id */
                        private static final long serialVersionUID = 1L;

                        @Override protected void onConfigure () { 
                                  setVisible (getList().size() < size); 
                                  super.onConfigure(); 
                                } 
                        
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, 
Form<?> form) {

                                List<T> targetList = 
PartialUpdateLimitedListView.this
                                                .getModelObject();
                                targetList.add(createNewItem());

                                if (target != null) {
                                        setResponsePage(getPage());
                                }
                        }
                }.setDefaultFormProcessing(false);
        }
----------------------------------------------------------------
protected T createNewItem() {
                if (type == null) {
                        throw new UnsupportedOperationException(
                                        "PartialUpdateListView#createNewItem: 
Type is null, and create item
isn't overridden");
                } else {
                        try {
                                return type.newInstance();
                        } catch (Exception e) {
                                throw new RuntimeException(
                                                
"PartialUpdateListView#createNewItem: Unable to generate a new
instance of a generic",
                                                e);
                        }
                }
        }

does anyone know how to resolve it ?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PropertyListView-issue-of-adding-multiple-instance-to-every-child-list-tp4678402.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to