cornerIcon
title
string
+ treeLink (do not generate a -componentActionURL but use the specified link)
Example:
TreeDataCell: WETreeData {
WOAssociation *string;
WOAssociation *icon;
WOAssociation *cornerIcon;
+ WOAssociation *treeLink;
BOOL doTable;
WOElement *template;
self->cornerIcon = WOExtGetProperty(_config, @"cornerIcon");
self->title = WOExtGetProperty(_config, @"title");
self->string = WOExtGetProperty(_config, @"string");
+ self->treeLink = WOExtGetProperty(_config, @"treeLink");
self->template = [_root retain];
}
- (void)dealloc {
[self->isTreeElement release];
+ [self->treeLink release];
[self->icon release];
[self->cornerIcon release];
[self->title release];
- (void)_appendLink:(NSString *)_icon resp:(WOResponse *)_response
ctx:(WOContext *)_ctx
{
- BOOL doForm = [_ctx isInForm];
-
+ BOOL doForm;
+
+ // doForm = [_ctx isInForm];
doForm = NO;
if (doForm) {
+ // TODO: we might want to support an assoc to provide the name
[_response appendContentString:@"<input type=\"image\" border=\"0\""];
[_response appendContentString:@" align=\"top\" name=\""];
[_response appendContentString:[_ctx elementID]];
[_response appendContentString:@"\" />"];
}
else {
+ NSString *link;
+
[_ctx appendElementIDComponent:WETreeView_ZOOM_ACTION_ID];
- [_response appendContentString:@"<a href=\""];
- [_response appendContentString:[_ctx componentActionURL]];
- [_response appendContentString:@"\">"];
+
+ link = (self->treeLink != nil)
+ ? [self->treeLink stringValueInComponent:[_ctx component]]
+ : [_ctx componentActionURL];
+
+ if ([link length] > 0) {
+ [_response appendContentString:@"<a href=\""];
+ [_response appendContentString:link];
+ [_response appendContentString:@"\">"];
+ }
[self _appendIcon:_icon alt:@"z" toResponse:_response inContext:_ctx];
- [_response appendContentString:@"</a>"];
+ if ([link length] > 0)
+ [_response appendContentString:@"</a>"];
+
[_ctx deleteLastElementIDComponent];
}
}
{
BOOL doLink;
NSString *img;
+ NSString *link;
+
+ // TODO: we need to patch this for stateless operation
+ link = nil;
doLink = (_key == WETreeView_Plus || _key == WETreeView_CornerPlus ||
_key == WETreeView_Minus || _key == WETreeView_CornerMinus);
+ if (doLink) {
+ if (self->treeLink) {
+ link = [self->treeLink stringValueInComponent:[_ctx component]];
+ if (link == nil)
+ doLink = NO;
+ }
+ }
+
+ img = [_ctx objectForKey:_key];
+ img = WEUriOfResource(img, _ctx);
- img = [_ctx objectForKey:_key];
- img = WEUriOfResource(img, _ctx);
-
if (_key == WETreeView_Leaf) {
NSString *tmp = [self->icon stringValueInComponent:[_ctx component]];
if (doLink) {
[_ctx appendElementIDComponent:WETreeView_ZOOM_ACTION_ID];
[_response appendContentString:@"<a href=\""];
- [_response appendContentString:[_ctx componentActionURL]];
+ [_response appendContentString:(link ? link :[_ctx componentActionURL])];
[_response appendContentString:@"\">"];
if (_key == WETreeView_Plus || _key == WETreeView_CornerPlus)
[_response appendContentString:@"<tt>[+]</tt>"];
else if (_key == WETreeView_Minus || _key == WETreeView_CornerMinus)
[_response appendContentString:@"<tt>[-]</tt>"];
-
+
[_response appendContentString:@"</a>"];
- [_ctx deleteLastElementIDComponent];
+ [_ctx deleteLastElementIDComponent]; /* WETreeView_ZOOM_ACTION_ID */
}
else if (_key == WETreeView_Leaf)
[_response appendContentString:@"<tt>-- </tt>"];
}
- (void)appendHeader:(WOResponse *)_response inContext:(WOContext *)_ctx {
- WOComponent *cmp = [_ctx component];
- NSString *tmp = [self->title stringValueInComponent:cmp];
- BOOL isTree = [self->isTreeElement boolValueInComponent:cmp];;
-
+ WOComponent *cmp;
+ NSString *tmp;
+ BOOL isTree;
+
+ cmp = [_ctx component];
+ tmp = [self->title stringValueInComponent:cmp];
+ isTree = [self->isTreeElement boolValueInComponent:cmp];;
+
if (tmp == nil)
return;
[_ctx component]]];
}
if (isTree) {
- [_response appendContentString:@" colspan=\""];
- [_response appendContentString:
+ [_response appendContentString:@" colspan=\""];
+ [_response appendContentString:
[[_ctx objectForKey:WETreeView_HEADER_MODE] stringValue]];
- [_response appendContentString:@"\"><nobr>"];
+ [_response appendContentString:@"\"><nobr>"];
}
else
[_response appendContentString:@"><nobr>"];