TabTestPage1 panel = new TabTestPage1(panelId);
AjaxFormValidatingBehavior.addToAllFormComponents(form,"onchange");
its the same problem: the panel hasnt been added to the form yet so none of the form components inside the panel have either.
i dont really see an easy way out of this and its because the component creation order is out of whack - something we fixed with constructor refactor in the upcoming 2.0
so the only way i see how to make it work now is to pass the form around and add the behavior manually instead of using the addtoall call.
-Igor
On 7/14/06, Macrae, Jeremy <[EMAIL PROTECTED]
> wrote:
Thanks for the advice.
I have tried what was suggested and now neither value in the model is
updated when switching between the tabs.
I'm fairly new to Wicket so I'm probably doing something wrong.
Below is some example code which demonstrates the problem -
public class TabTestPage extends AuthenticatedWebPage {
static TestModel model = null;
public TabTestPage() {
model = new TestModel("A", "B");
final Form form = new Form("TabTest");
this.setModel(new CompoundPropertyModel(model));
List tabs = new ArrayList();
tabs.add(new AbstractTab(new Model("Tab1")) {
public Panel getPanel(final String panelId) {
TabTestPage1 panel = new TabTestPage1(panelId);
AjaxFormValidatingBehavior.addToAllFormComponents(form,
"onchange");
return panel;
}
});
tabs.add(new AbstractTab(new Model("Tab2")) {
public Panel getPanel(final String panelId) {
TabTestPage2 panel = new TabTestPage2(panelId);
AjaxFormValidatingBehavior.addToAllFormComponents(form,
"onchange");
return panel;
}
});
TabbedPanel panel = new TabbedPanel("Tabs", tabs);
form.add(panel);
add(form);
}
private static class TabTestPage1 extends Panel {
public TabTestPage1(final String id) {
super(id);
TextField field = new TextField("Test1");
add(field);
}
};
private static class TabTestPage2 extends Panel {
public TabTestPage2(final String id) {
super(id);
TextField field = new TextField("Test2");
add(field);
}
};
class TestModel {
private String test1;
private String test2;
public TestModel(final String test1, final String test2) {
this.test1 = test1;
this.test2 = test2;
}
public void setTest1(final String test1) {
this.test1 = test1;
}
public String getTest1() {
return this.test1;
}
public void setTest2(final String test2) {
this.test2 = test2;
}
public String getTest2() {
return this.test2;
}
}
}
-------------------------
From: "Igor Vaynberg" < [EMAIL PROTECTED]>
Subject: Re: [Wicket-user] Setting model values in a TabbedPanel
To: wicket-user@lists.sourceforge.net
Message-ID:
< [EMAIL PROTECTED]>
Content-Type: text/plain; charset="windows-1252"
probably because this call:
AjaxFormValidatingBehavior.addToAllFormComponents(form, "onchange");
will only modify form components in the hierarchy - since your second
tab is not in the hierarchy until you switch to it the form components
in it are not affected
you have to make this call as part of the setup of the tab in the
getPanel() method or in the panel's constructor.
-Igor
On 7/13/06, Macrae, Jeremy <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
>
>
> I am having a problem setting values in a model via the panels on a
> TabbedPanel.
>
>
>
> I have a page which contains a form containing a TabbedPanel with two
> AbstractTab panels.
>
> Each of these panels contains a single Textbox.
>
> I want to use the same model for the whole form so have called ?
>
>
>
> form.setModel (new CompoundPropertyModel(model)
>
>
>
> I want Ajax validation on the form so have called -
>
>
>
> AjaxFormValidatingBehavior.addToAllFormComponents(form, "onchange");
>
>
>
> The first panel works correctly. Tabbing out of the TextfField or
> selecting the second tab causes the corresponding set method on the
model to
> be called.
>
> The second panel does not work the same way. The set method is not
called.
>
> If I swap the tabs over the first one again works correctly.
>
>
>
> Is there any way I can get this to work?
>
>
>
> Thanks
>
>
>
> This email and any files transmitted with it are confidential,
proprietary
> and intended solely for the individual or entity to whom they are
addressed.
> If you have received this email in error please delete it
immediately.
>
>
>
>
------------------------------------------------------------------------
-
> Using Tomcat but need to do more? Need to support web services,
security?
> Get stuff done quickly with pre-integrated technology to make your
job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
> _______________________________________________
> Wicket-user mailing list
> [EMAIL PROTECTED] ...
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user