On Tuesday 07 March 2006 20:11, Leo Sakhvoruk wrote:
> Hi everyone,
>
> I'm trying to manipulate components inside a form and am having trouble
> casting them correctly. What class should components be cast to since
> they're enhanced?
I found the easiest way is to inject them as per this example
@InjectComponent("newrole")
public abstract TextField getNewRoleField();
public void updateRoles() {
if (getButtonClicked() < 0) {
/*
* Create a new role
*/
ValidRole vr = getNewRole();
if (!(vr.getName() == null || vr.getName().equals("")))
{
try{
vr.create();
} catch (DatabaseException e) {
ValidationDivDelegate delegate =
getDelegate();
delegate.setFormComponent(getNewRoleField());
delegate.record(getMessages().getMessage("error.naming"),ValidationConstraint.CONSISTENCY);
return;
}
setNewRole(null); //Clear out the field so its
not detected next time
}
}
}
}
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]