why not something more directly like:
*public class ProvaLink extends ResourceLink {
ResourceReference resourceReference;
....
@Override
public boolean isVisible() {
if(resourceReference==null)return false;
else return true;
}
}
*hope to help...
Luca
2009/10/14 Iain Reddick <[email protected]>
> I think my best solution is to use a lightweight container like this:
>
> public class NullableContainer extends WebMarkupContainer {
>
> public NullableContainer(String id) {
> super(id);
> }
> public NullableContainer(String id, IModel model) {
> super(id, model);
> }
>
> @Override
> protected void onBeforeRender() {
> super.onBeforeRender();
> onPopulate(); }
> /**
> * Convenience method for lazy-adding of children
> */
> protected void onPopulate() {
> }
>
> @Override
> public boolean isVisible() {
> return getModelObject() != null;
> }
> }
>
> I then can override onPopulate() and add my children that depend on the
> nullable for construction.
> It's basically the logic equivalent of "if model is not null, add
> children".
>
>
> Iain Reddick wrote:
>
>> I'm fishing for best practice in this type of situation - do I use the
>> solution you outlined, or do I add a simple invisible dummy link instead of
>> the the resource link, or is there a better solution that I'm missing?
>>
>> Luca Provenzani wrote:
>>
>>> i don't understand the problem....
>>>
>>> can't you check the resource before link is rendered?
>>> You can create a new resource object empty in the case of null
>>> bytes....and
>>> setVisible(false) or extend link to do this automatically on empty
>>> resource...
>>>
>>> Luca
>>>
>>> 2009/10/14 Iain Reddick <[email protected]>
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I need to display a resource link conditionally, based on whether a
>>>> resource exists, or is null. The resource itself is bytes in a database
>>>> and
>>>> should not be anchored to a component.
>>>>
>>>> How should I handle this, with regard to the resource being nullable?
>>>>
>>>> Thanks.
>>>>
>>>> iainr
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>