On Thu, 08 Nov 2007, Toscano wrote:
> IModel regionModelChoices = new AbstractReadOnlyModel()
> {
> public Object getObject(Component component)
> {
> if (professionalInfo.getCountryWork()!=null)
> regions =
> getRegionDaoInterface().getRegions(professionalInfo.getCountryWork().getCountryID());
You could extract a method of that monster :)
For example private boolean selectedCountryHasRegions(), or
even professionalInfo.getCountryWork().hasRegions(getRegionDao());
> if (regions.size()==0)
> regionWork.setEnabled(false);
> else
> regionWork.setEnabled(true);
And instead of testing for size == 0 call isEmpty(), and the
formatting here is kind of unconventional as well (Eclipse
3.3 has the nice new possibility of adding Save actions such
as reformat code).
> regionWork = new DropDownChoice("regionWork", new Model(),
> regionModelChoices,
> new ChoiceRenderer("regionName", "regionID"));
> regionWork.setOutputMarkupId(true);A
regionWork = new DropDownChoice(...) {
@Override
public boolean isEnabled() {
return selectedCountryHasRegions();
}
or it it doesn't work
regionWork = new DropDownChoice(...) {
@Override
public void onBeforeRender() {
super.onBeforeRender();
setEnabled(selectedCountryHasRegions());
}
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]