You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tito <nj...@gmail.com> on 2010/09/30 19:15:31 UTC

Forms ajax doesn't update components models

Hello,

I'm doing a form that adds textfields when I choose an option in a ComboBox.
When Combo changes one panel become visible and other invisible.
The problem is when that panel appears and I click submit button the model
of it does't update.
I have seen that browser submit the info, but wicket doesn't process it. I
don't know if i'm doing anything wrong or is a known problem.

Thank you.
Excuse me for my bad English. I'm from Argentina.

Norberto

Re: Forms ajax doesn't update components models

Posted by vov <vo...@mail.ru>.
How it currently must work?
Example:
Your open the page -> change your Combo to 'AUTO' -> input data to
AutoInfoPanel and press 'Registrar'
OR
Your open the page -> change your Combo to 'AUTO' -> input data to
AutoInfoPanel -> change your Combo to 'PERSONA' -> input data to
PersonaInfoPanel and press 'Registrar'.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2854298.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
Here is the panel java source (reduced):

public class DispositivoPanel extends Panel {

    public DispositivoPanel(String id, final IModel<DispositivoDTO> model) {
        super(id);

        // creo el formulario de usuario
        Form<Void> form = new Form<Void>("registracion") {

            @Override
            protected void onSubmit() {
                DispositivoPanel.this.onSubmit(model);
            }
        };

        form.add(new RequiredTextField<String>("nombre", new
PropertyModel<String>(model, "nombre")));

        final WebMarkupContainer contenedorInfo = new
WebMarkupContainer("contenedor_info");
        contenedorInfo.setOutputMarkupId(true);

        // Seleccionador de tipo de dispositivo.
        List<TipoDispositivo> tipos = new ArrayList<TipoDispositivo>();
        tipos.add(TipoDispositivo.BASE);
        tipos.add(TipoDispositivo.AUTO);
        tipos.add(TipoDispositivo.PERSONA);

        DropDownChoice<TipoDispositivo> drop = new
DropDownChoice<TipoDispositivo>("tipo",
                new PropertyModel<TipoDispositivo>(model, "tipo"), tipos,
new TipoDispositivoRenderer());
        drop.add(new AjaxFormComponentUpdatingBehavior("onChange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                target.addComponent(contenedorInfo);
            }
        });
        form.add(drop);

        // creamos los paneles de info
        contenedorInfo.add(new AutoInfoPanel("auto_info_panel", model) {

            @Override
            public boolean isVisible() {
                return
model.getObject().getTipo().equals(TipoDispositivo.AUTO);
            }
        });
        contenedorInfo.add(new PersonaInfoPanel("persona_info_panel", model)
{
            @Override
            public boolean isVisible() {
                return
model.getObject().getTipo().equals(TipoDispositivo.PERSONA);
            }
        });

        form.add(contenedorInfo);

        add(form);
    }

    protected void onSubmit(IModel<DispositivoDTO> model) {
    }
}


And here html of panel:

<wicket:panel>
    <div wicket:id="feedback" />
    <form wicket:id="registracion" name="dispositivo_form">
    <fieldset><legend>Información del dispositivo:</legend>
    <ol>
        <li>
            <label>Nombre del Dispositivo:*</label>
            <input wicket:id="nombre" type="text" name="nombre" />
        </li>
        <li>
            <label>Tipo: </label>
            <select wicket:id="tipo" />
        </li>
    </ol>

    <div wicket:id="contenedor_info">
        <DIV wicket:id="auto_info_panel" />
        <DIV wicket:id="persona_info_panel" />
    </div>
    </fieldset>


    <fieldset class="submit"><span class="required">*Campos
requeridos</span> <br />
        <input type="submit" value="Registrar" />
    </fieldset>
    </form>
    <script language="JavaScript">
        document.dispositivo_form.nombre.focus();
    </script>
</wicket:panel>


The idea is part of form is static and part of it is dynamic, updated by
ajax. It depends on combo selection (this is working) but, when you click
"Registrar" button, data from "auto_info_panel" don't appear in
DispositivoDTO model.

Thanks for answer me!

Norberto


2010/9/30 Per Newgro <pe...@gmx.ch>

>  Can you please share some code. Otherwise there could be tons of problem
> causes.
>
> Cheers
> Per
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Forms ajax doesn't update components models

Posted by Per Newgro <pe...@gmx.ch>.
  Can you please share some code. Otherwise there could be tons of 
problem causes.

Cheers
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
It was a Wicket 1.5-M1 bug!!!!!

I made a quickstart accidentally in wicket 1.5-M2.1 and it worked.

The problem is that wicket 1.5-M2 don't have HeaderContributor anymore haha.

Well thanks for every body, I wanted to warn.
Bye

Tito

2010/10/7 Tito <nj...@gmail.com>

> I made a quickstart and it works.
>
> Now I'm looking for the bug in my application.
>
> Thanks
>
> Tito
>
> 2010/10/6 Tito <nj...@gmail.com>
>
> Well thank you!!
>>
>> I'm going to see this. If I see another details or if I can solve I will
>> tell you.
>>
>> Thank you very much for helping!
>>
>> Bye
>>
>>
>> 2010/10/6 vov <vo...@mail.ru>
>>
>>
>>> Sorry, but I'm not see the problems.
>>> Try to debug your isVisible method after submitting the form and find the
>>> place in which this code return false. I think that
>>> isVisibleInHierarchy()
>>> for your RequiredTextField<String>("patente") will have a problem
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2964459.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
I made a quickstart and it works.

Now I'm looking for the bug in my application.

Thanks

Tito

2010/10/6 Tito <nj...@gmail.com>

> Well thank you!!
>
> I'm going to see this. If I see another details or if I can solve I will
> tell you.
>
> Thank you very much for helping!
>
> Bye
>
>
> 2010/10/6 vov <vo...@mail.ru>
>
>
>> Sorry, but I'm not see the problems.
>> Try to debug your isVisible method after submitting the form and find the
>> place in which this code return false. I think that isVisibleInHierarchy()
>> for your RequiredTextField<String>("patente") will have a problem
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2964459.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
Well thank you!!

I'm going to see this. If I see another details or if I can solve I will
tell you.

Thank you very much for helping!

Bye


2010/10/6 vov <vo...@mail.ru>

>
> Sorry, but I'm not see the problems.
> Try to debug your isVisible method after submitting the form and find the
> place in which this code return false. I think that isVisibleInHierarchy()
> for your RequiredTextField<String>("patente") will have a problem
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2964459.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Forms ajax doesn't update components models

Posted by vov <vo...@mail.ru>.
Sorry, but I'm not see the problems.
Try to debug your isVisible method after submitting the form and find the
place in which this code return false. I think that isVisibleInHierarchy()
for your RequiredTextField<String>("patente") will have a problem
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2964459.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
Sorry feedback panel error was part of my coding prune to post.

I can see submit method is called but data never appear. However other data
of form that is not in auto_info_panel appears in model.

In your tests data of map was setting to model??

The curious case is that when I change isVisible method of Auto_Info_Panel
to

       contenedorInfo.add(new AutoInfoPanel("auto_info_panel", model) {

            @Override
            public boolean isVisible() {
                return
model.getObject().getTipo().equals(TipoDispositivo.AUTO) || true;
            }
        });

Form start to work. Model is full filled.

Could be a wicket 1.5 problem?? did you test in wicket 1.4?

Thank you!

Norberto

2010/10/5 vov <vo...@mail.ru>

>
> Funny:) Your code is correct and in my tests all data was setting to
> model:)
> In your sample code you forgot to include feedback panel, but it was added
> to html.
> May be in your tests you forget to input some required data - in this case
> your model never updates but you also never been in your onSubmit method.
>
> Problem can be in any validation problem or in visibility of component or
> your component can be disabled
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2955537.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Forms ajax doesn't update components models

Posted by vov <vo...@mail.ru>.
Funny:) Your code is correct and in my tests all data was setting to model:)
In your sample code you forgot to include feedback panel, but it was added
to html.
May be in your tests you forget to input some required data - in this case
your model never updates but you also never been in your onSubmit method.

Problem can be in any validation problem or in visibility of component or
your component can be disabled
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2955537.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms ajax doesn't update components models

Posted by Tito <nj...@gmail.com>.
mmm... you think is my model?
Could be, but debugging wicket I found never was called setObject method of
my model.
I'm using wicket 1.5 I know this doesn't matter but I never mentioned.

Here is my AutoInfoPanel. The idea is to update a Map that contains data.
There are three maps in my auto_info_panel but I reduced this for
simplicity. Three are the same.

Java:

public class AutoInfoPanel extends Panel {

public AutoInfoPanel(String id, final IModel<DispositivoDTO> model) {
 super(id, model);

add(new RequiredTextField<String>("patente", new IModel<String>() {

@Override
public void detach() {
}

@Override
public String getObject() {
return model.getObject().getInfo().get("patente");
 }

@Override
public void setObject(String object) {
 model.getObject().getInfo().put("patente", object);
}

 }));
}
}

And HTML:

<wicket:panel>
     <fieldset>
     <legend>Información del Automóvil:</legend>
 <ol>
 <li>
<label>Patente:*</label>
                        <input wicket:id="patente" type="text" />
 </li>
 </ol>
 </fieldset>
 </wicket:panel>


Thanks for following this thread!!

Tito

2010/10/4 vov <vo...@mail.ru>

>
> Your code looks correct.
> You said 'when you click "Registrar" button, data from "auto_info_panel"
> don't appear in DispositivoDTO model'.
>
> I tried to create AutoInfoPanel like this:
>
> public AutoInfoPanel(String id, IModel<DispositivoDTO> model)
>  {
>    super(id);
>    add(new TextField<String>("lastName", new PropertyModel<String>(model,
> "lastName")));
>  }
> ..and HTML:
> <wicket:panel>
>        LastName<input type="text" wicket:id=lastName>
> </wicket:panel>
>
> ..and in your onSubmit(IModel<DispositivoDTO> model) method i take the last
> name from bean model wich I input in the form.
>
> Can your share your AutoInfoPanel code for better understanding the
> problem?
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2953949.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Forms ajax doesn't update components models

Posted by vov <vo...@mail.ru>.
Your code looks correct.
You said 'when you click "Registrar" button, data from "auto_info_panel"
don't appear in DispositivoDTO model'.

I tried to create AutoInfoPanel like this:

public AutoInfoPanel(String id, IModel<DispositivoDTO> model)
  {
    super(id);
    add(new TextField<String>("lastName", new PropertyModel<String>(model,
"lastName")));
  }
..and HTML:
<wicket:panel>
  	LastName<input type="text" wicket:id=lastName>
</wicket:panel>

..and in your onSubmit(IModel<DispositivoDTO> model) method i take the last
name from bean model wich I input in the form.

Can your share your AutoInfoPanel code for better understanding the problem?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Forms-ajax-doesn-t-update-components-models-tp2730857p2953949.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org