You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Iamuser <su...@gmail.com> on 2016/06/20 12:01:45 UTC

Change column visibility or text based on combo selected value

Hi,
I'm using wicket 6.

I have a combo and a table that contains a fixed number of rows and columns.
Based on the value chosen inside the combo, the first column of the table
should change it's text. 
Basically the first column contains in every cell, the same text, that needs
to change when something else is selected in the combo.


Could you please advise what is the best approach to do this?
Thank you

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943.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: Change column visibility or text based on combo selected value

Posted by Iamuser <su...@gmail.com>.
Hello,

In the form2 I need to display values from other models than in form1, but
that are dependent on the values from the form1 model.




On Tue, Jun 28, 2016 at 4:42 PM, Sven Meier [via Apache Wicket] <
ml-node+s1842946n4674974h28@n4.nabble.com> wrote:

> After form submit the whole page will be re-rendered anyway, including
> your form2. So you should not need to do anything additional here.
>
> Make sure your form2 is properly bound to your model objects:
>
> https://ci.apache.org/projects/wicket/guide/6.x/guide/modelsforms.html
>
> Have fun
> Sven
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674974.html
> To unsubscribe from Change column visibility or text based on combo
> selected value, click here
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4674943&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc0OTQzfC01MzM2MjU4NzI=>
> .
> NAML
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4675011.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: Change column visibility or text based on combo selected value

Posted by Iamuser <su...@gmail.com>.
Here is a test sample of how constructor for Form2 class looks like:
Form2 should update both childId and parentName, when child changes in
form1.
However, I only get the childId updated; parentName does not change.


public Form2(String id, IModel<Child> form1model) {
super(id,model);
Label lblChild = new Label("childId", new PropertyModel<String>(form1model,
"Id"));
add(lblChild);
IModel<Patent> modelParent = null;
if (form1model.getObject().getId() != null) {
Parent par =
SpringCtx.getAppDB(ParentDao.class).selectById(form1model.getObject().getId());
modelParent = new Model<Parent>(par);
}
else
modelParent = new Model<Parent>();
Label lblParentName = new Label("parentName", new
PropertyModel<String>(modelParent, "Name"));
add(lblParentName);
}
Thank you for your help.

On Sun, Jul 3, 2016 at 12:06 AM, ganea iulia <su...@gmail.com> wrote:

> Hello,
>
> In the form2 I need to display values from other models than in form1, but
> that are dependent on the values from the form1 model.
>
>
>
>
> On Tue, Jun 28, 2016 at 4:42 PM, Sven Meier [via Apache Wicket] <
> ml-node+s1842946n4674974h28@n4.nabble.com> wrote:
>
>> After form submit the whole page will be re-rendered anyway, including
>> your form2. So you should not need to do anything additional here.
>>
>> Make sure your form2 is properly bound to your model objects:
>>
>> https://ci.apache.org/projects/wicket/guide/6.x/guide/modelsforms.html
>>
>> Have fun
>> Sven
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674974.html
>> To unsubscribe from Change column visibility or text based on combo
>> selected value, click here
>> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4674943&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc0OTQzfC01MzM2MjU4NzI=>
>> .
>> NAML
>> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4675012.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: Change column visibility or text based on combo selected value

Posted by Sven Meier <sv...@meiers.net>.
After form submit the whole page will be re-rendered anyway, including your
form2. So you should not need to do anything additional here.

Make sure your form2 is properly bound to your model objects:

https://ci.apache.org/projects/wicket/guide/6.x/guide/modelsforms.html

Have fun
Sven

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674974.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: Change column visibility or text based on combo selected value

Posted by Iamuser <su...@gmail.com>.
Hi,
Thank you for the help.
Now the requirement has changes, to update form2 after the submit of form1.
On form1:
SubmitLink lnk = new SubmitLink("saveSubmitLink") {
---
}
form1.add(lnk);

So, after the save of form1, I need to refresh the date on form2.

Could you please advise?

Thank you so much.

On Wed, Jun 22, 2016 at 3:37 PM, Sven Meier [via Apache Wicket] <
ml-node+s1842946n4674953h77@n4.nabble.com> wrote:

> Hi,
>
> you're using a DropDownChoice? Then you have to use
> AjaxFormComponentUpdatingBehavior (note no "Choice" here).
>
> AjaxFormChoiceComponentUpdatingBehavior is to be used with Wicket input
> components which have multiple <input> tags in the resulting HTML.
>
> Have fun
> Sven
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674953.html
> To unsubscribe from Change column visibility or text based on combo
> selected value, click here
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4674943&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc0OTQzfC01MzM2MjU4NzI=>
> .
> NAML
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674971.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: Change column visibility or text based on combo selected value

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you're using a DropDownChoice? Then you have to use
AjaxFormComponentUpdatingBehavior (note no "Choice" here).

AjaxFormChoiceComponentUpdatingBehavior is to be used with Wicket input
components which have multiple <input> tags in the resulting HTML.

Have fun
Sven

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674953.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: Change column visibility or text based on combo selected value

Posted by Iamuser <su...@gmail.com>.
Hi,
Thank you for the tip.

One issue that I'm facing now is that the listView is in one form on the
page (form1), and the table with the column is in another form on the same
page (form2).

=If in my form1 I call:

itemSelect.add(new AjaxFormChoiceComponentUpdatingBehavior() {
private static final long serialVersionUID = 8119676745783499408L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(form2);
}
});


The following error is thrown:

Caused by: org.apache.wicket.WicketRuntimeException: Behavior
gui.proc.management.interference.Page1$Form1$5 can only be added to an
instance of a RadioChoice/CheckboxChoice/RadioGroup/CheckGroup

Thank you so much for your help.


On Mon, Jun 20, 2016 at 3:49 PM, Sven Meier [via Apache Wicket] <
ml-node+s1842946n4674945h29@n4.nabble.com> wrote:

> Hi,
>
> you should use a column that always displays the correct text:
>
>   new AbstractColumn<Foo>(Model.of("Text")) {
>     public void populateItem(Item<ICellPopulator<Foo>> cellItem, String
> componentId, IModel<Foo> rowModel) {
>       cellItem.add(new Label(componentId), new
> AbstractReadOnlyModel<String>() {
>         public String getObject() {
>           return getColumnText();
>         }
>       });
>     }
>   }
>
> This way you just have to update the whole table via Ajax when your
> dropDown changes, e.g.
>
>   dropDown.add(new AjaxFormChoiceComponentUpdatingBehavior() {
>     protected void onUpdate(AjaxRequestTarget target) {
>       target.add(table);
>     }
>   });
>
> Hope this helps
> Sven
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674945.html
> To unsubscribe from Change column visibility or text based on combo
> selected value, click here
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4674943&code=c3VwZXJiaXNzaW1hQGdtYWlsLmNvbXw0Njc0OTQzfC01MzM2MjU4NzI=>
> .
> NAML
> <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674952.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: Change column visibility or text based on combo selected value

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you should use a column that always displays the correct text:

  new AbstractColumn<Foo>(Model.of("Text")) {
    public void populateItem(Item<ICellPopulator&lt;Foo>> cellItem, String
componentId, IModel<Foo> rowModel) {
      cellItem.add(new Label(componentId), new
AbstractReadOnlyModel<String>() {
        public String getObject() {
          return getColumnText();
        }
      });
    }
  }

This way you just have to update the whole table via Ajax when your dropDown
changes, e.g.

  dropDown.add(new AjaxFormChoiceComponentUpdatingBehavior() {
    protected void onUpdate(AjaxRequestTarget target) {
      target.add(table);
    }
  });

Hope this helps
Sven

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Change-column-visibility-or-text-based-on-combo-selected-value-tp4674943p4674945.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