I have a form which extends wicket form: MyForm extends Form
In the constructor, I have this line: super(formId, new CompoundPropertyModel(new SignUpFormModel())); SignUpFormModel is a Java class that contains my form fields. After the super call, i add the components: fc = new RequiredTextField("userName"); fc.add(StringValidator.minimumLength(4)); fc.setLabel(new Model("User name")); fc.add(new AjaxFormComponentUpdatingBehavior("onChange") { protected void onUpdate(AjaxRequestTarget target) { } }); add(fc); fc = new Button("checkId"); fc.add(new AjaxFormComponentUpdatingBehavior("onClick") { protected void onUpdate(AjaxRequestTarget target) { // this works String userName =((SignUpFormModel) getComponent().getParent().getModelObject()).getUserName(); // this doesn't work //String userName =((SignUpFormModel) getComponent().getModelObject()).getUserName(); if(userInfoService.checkIsUniUsername(userName)) getComponent().info("User Id is available."); else getComponent().error("User Id is unavailable."); target.addComponent(((SignUpWindow) getComponent().getPage()).getFeedback()); } }); add(fc); All that code is inside my form class. I think I see what you mean, when i create my form component, i don't pass in a model to it. I pass in my model to the form instead. Could you suggest a best approach on how to do this? If I want to pass in a model for the component, do I just pass in my form model when i do a new form component? igor.vaynberg wrote: > > you most likely did not give the formcomponent a model. > > paste the relevant code > > -igor > > > On 4/28/07, wicket0123 <[EMAIL PROTECTED]> wrote: >> >> >> >> when i use getformcomponent.getmodleobject inside the onupdate, it throws >> nullpointer exeption. see code below, >> >> ((SignUpFormModel) getFormComponent().getModelObject()).getUserName() >> >> If I use this, i have no problem: >> >> ((SignUpFormModel) >> getComponent().getParent().getModelObject()).getUserName(); >> >> Not sure if this is a bug on wicket or my code... >> >> >> >> igor.vaynberg wrote: >> > >> > if you use wicket validators and the component is invalid the onerror() >> > will >> > be called instead of onupdate() >> > >> > the value is available via getformcomponent().getmodelobject() inside >> > onupdate() >> > >> > -igor >> > >> > >> > On 4/27/07, wicket0123 <[EMAIL PROTECTED]> wrote: >> >> >> >> >> >> I want to use ajax to check if a field value is valid w/o submitting >> the >> >> entire form. I add AjaxFormComponentUpdatingBehavior to my ajax >> object >> >> (link/button/etc). But, I don't know how to retrieve the edit field's >> >> value >> >> inside the onUpdate method. See the code I have: >> >> >> >> fc = new RequiredTextField("userName"); >> >> fc.setLabel(new Model("User Name")); >> >> add(fc); >> >> >> >> fc = new Button("checkId"); >> >> fc.add(new >> AjaxFormComponentUpdatingBehavior("onClick") >> { >> >> protected void onUpdate(AjaxRequestTarget >> target) >> >> { >> >> >> >> System.out.println("This gets >> called"); >> >> >> >> // TODO: how to get the userName >> field's >> >> value? >> >> >> >> >> >> } >> >> }); >> >> >> >> add(fc); >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/how-to-get-a-form%27s-field-when-i-click-on-an-ajax-object-tf3660473.html#a10228341 >> >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> >> >> >> >> ------------------------------------------------------------------------- >> >> This SF.net email is sponsored by DB2 Express >> >> Download DB2 Express C - the FREE version of DB2 express and take >> >> control of your XML. No limits. Just data. Click to get it now. >> >> http://sourceforge.net/powerbar/db2/ >> >> _______________________________________________ >> >> Wicket-user mailing list >> >> Wicket-user@lists.sourceforge.net >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user >> >> >> > >> > >> ------------------------------------------------------------------------- >> > This SF.net email is sponsored by DB2 Express >> > Download DB2 Express C - the FREE version of DB2 express and take >> > control of your XML. No limits. Just data. Click to get it now. >> > http://sourceforge.net/powerbar/db2/ >> > _______________________________________________ >> > Wicket-user mailing list >> > Wicket-user@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/wicket-user >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/how-to-get-a-form%27s-field-when-i-click-on-an-ajax-object-tf3660473.html#a10237360 >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Wicket-user mailing list >> Wicket-user@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/wicket-user >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > -- View this message in context: http://www.nabble.com/how-to-get-a-form%27s-field-when-i-click-on-an-ajax-object-tf3660473.html#a10295090 Sent from the Wicket - User mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user