Re: Disable displaying contents of WOComponent
Re: Disable displaying contents of WOComponent
- Subject: Re: Disable displaying contents of WOComponent
- From: Freddie Tilley <email@hidden>
- Date: Thu, 26 Jun 2008 16:38:22 +0200
I'm currently testing with this code, but the problem is once the
elements have been removed, they
do not return until I restart the webobjects app.
There must be some easier way of doing this
Freddie Tilley
Hello, I'm trying to build a permission system that will disable
the contents of the entire component.
I guess normally I should override appendToResponse and disable
the writing of the component contents
there. But the problem is if I have a wrapper in the component I
still want to show the wrapper contents
so the wrapper will show everything apart from the
<wo:WOComponentContent />
The way I do it now is override the components template() method
and disable the elements that
should not be visible. My question is, is this the correct way of
doing it, and if so, are
there any hidden problems with doing it this way. The template
override code is this:
public WOElement template() {
WOElement tmpl = super.template();
if (!canViewComponent())
{
NSMutableArray<WOElement> children =
((WODynamicGroup)tmpl).childrenElements();
NSMutableArray<WOElement> removeElements = new
NSMutableArray<WOElement>();
for (WOElement el : children) {
if (el instanceof WOComponentReference) {
WODynamicGroup dg = (WODynamicGroup)
((WOComponentReference)el)._contentElement;
NSArray<WOElement> childrenElements = dg.childrenElements();
if (childrenElements != null) {
/* this element is the wrapper, only disable the
* content elements
*/
((WOComponentReference)el)._contentElement = null;
} else {
removeElements.add(el);
}
} else {
removeElements.add(el);
}
}
children.removeObjectsInArray(removeElements);
}
return tmpl;
}
Freddie Tilley
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden