Hi,

in my Page (not relevant code removed for simplicity) is dropdown:
public class MyPage extends WebBase{
    //perie
    private Model<Perie> modelPerie;
    //two values in dropdown:
    private List<Perie> perie = Arrays.asList(new Perie("start", "-Vyberte druh peří-"), new 
Perie("vsypek", "nové 806"));
    private DropDownChoice<Perie> vyberPeria;
    private ChoiceRendererPerie rendererPerie;
    public PageEshop(){
        this.rendererPerie = new ChoiceRendererPerie();
        this.modelPerie = new Model<Perie>(this.perie.get(0));
        this.vyberPeria = new DropDownChoice<Perie>("vyberPeria", 
this.modelPerie, this.perie, this.rendererPerie);
        MyForm form = new MyForm("inputForm");
        form.add(vyberPeria);
        this.add(form);
    }

    private class MyForm extends Form<Object>{
        public MyForm(String id){
            super(id);
        }

        @Override
        protected void onSubmit(){
            //with value added with jquery this produce error
            
System.out.println(PageEshop.this.modelPerie.getObject().getHodnota());
        }
    }
}

and in relevant markup I add new choice in this dropdown with jquery:
<form wicket:id="inputForm">
    <div id="perie">
        <label>Typ peří:</label>
        <select id="2" wicket:id="vyberPeria"></select>
    </div>
    <script>
    jQuery(document).ready(
            function()
            {
                //-->this add another value into dropdown, now there are three 
values:
                
$('#2').append($('<option></option>').val('testkluc').html('testovaci text'));
            })
    </script>
</form>

Of course, when I select this added value ('testkluc') in dropdown and submit 
it, from onSubmit() I try to do something with this, I get error:
...
java.lang.reflect.InvocationTargetException
...PageEshop$MyForm.onSubmit(...

Yes, I know that this third value isn't in model so error is predictable. 
Question is: how to deal with situation when I need
add new value in HTML and this value isn't in my model in java?

Thanks,

MJ

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

Reply via email to