Hi Bob,

Thanks, that worked fine. Now I don't have a dependency anymore and the
control can be used anywhere in the application. I preffer to let the
control do the work, adding a extern Decorator makes the Control less
usefull.

Regards Bert

2008/12/2 Bob Schellink <[EMAIL PROTECTED]>

> Hi Bert,
>
>
> Bert Heikamp wrote:
>
>>
>> if (parent2 instanceof SimpleTable) {
>>
>>    Page page = ((SimpleTable)parent2).getPage();
>>
>>    PageImports pageImports = getPage().getPageImports();
>>
>>    pageImports.addImport(getControlField());
>>
>> }
>>
>
>
> You could retrieve the parent page as follows:
>
>  Page page = ClickUtils.getParentPage(this);
>
> getParentPage will recursively check for the parent Page up the hierarchy.
> This call should always succeed in retrieving the Page.
>
>
> Alternatively you could look at using a Decorator instead of overriding
> render, as that will provide you a callback mechanism to set the field value
> to some default:
>
>  final FieldColumn column = new  FieldColumn("time", field);
>  column.setDecorator(new Decorator() {
>
>    public String render(Object row, Context context) {
>      Field field = column.getField();
>
>      // If field is blank, set default value
>      if (StringUtils.isBlank(field.getValueObject())) {
>        field.setValue("12:00");
>      }
>
>      return field.toString();
>    }
>  });
>
> Will this work in your scenario?
>
> kind regards
>
> bob
>

Reply via email to