Skip to content

Commit

Permalink
Merge pull request #362 from ishimoto/TargetFix
Browse files Browse the repository at this point in the history
Add 'target' Binding to ERAttachmentLink
  • Loading branch information
ishimoto committed Jan 19, 2013
2 parents cca6f71 + 5069fd3 commit eedfed2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8"?>
<wodefinitions>
<wo class="ERAttachmentFlexibleEditor" wocomponentcontent="false"> <binding name="masterObject"/>
<binding name="relationshipKey"/>
Expand Down Expand Up @@ -40,5 +40,6 @@
<binding name="uploadSelectFileButtonClass"/>
<binding name="uploadSelectFileLabel"/>
<binding name="uploadStartedFunction"/>
<binding name="viewTarget"/>
</wo>
</wodefinitions>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ERAttachmentLink : ERAttachmentLink {
attachment = viewerAttachment;
download = allowDownload;
configurationName = ^configurationName;
target = ^viewTarget;
}

OriginalFileName : WOString {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8"?>
<wodefinitions>
<wo class="ERAttachmentLink" wocomponentcontent="true">
<binding name="attachment"/>
Expand All @@ -11,5 +11,6 @@
<unbound name="attachment"/>
</validation>
<binding defaults="Boolean" name="download"/>
<binding name="target"/>
</wo>
</wodefinitions>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import er.attachment.processors.ERAttachmentProcessor;
import er.extensions.components.ERXComponentUtilities;
import er.extensions.foundation.ERXMutableURL;
import er.extensions.foundation.ERXStringUtilities;

/**
* ERAttachmentLink is like a WOHyperlink that points to an attachment's contents.
Expand All @@ -30,6 +31,7 @@
*/
public class ERAttachmentLink extends WODynamicGroup {
private WOAssociation _attachment;
private WOAssociation _target;
private WOAssociation _configurationName;
private NSMutableDictionary<String, WOAssociation> _associations;
private WOAssociation _download;
Expand All @@ -39,6 +41,7 @@ public ERAttachmentLink(String name, NSDictionary<String, WOAssociation> associa
_associations = associations.mutableClone();
_attachment = _associations.removeObjectForKey("attachment");
_download = _associations.removeObjectForKey("download");
_target = _associations.removeObjectForKey("target");
if (_attachment == null) {
throw new WODynamicElementCreationException("<ERAttachmentLink> The 'attachment' binding is required.");
}
Expand Down Expand Up @@ -73,6 +76,14 @@ public void appendToResponse(WOResponse response, WOContext context) {
}
response.appendContentString(attachmentUrl);
response.appendContentString("\"");

if (_target != null) {
String sTarget = (String) _target.valueInComponent(component);
if(!ERXStringUtilities.stringIsNullOrEmpty(sTarget)) {
response.appendContentString(" target=\"" + sTarget +"\"");
}
}

ERXComponentUtilities.appendHtmlAttributes(_associations, response, component);
response.appendContentString(">");
super.appendToResponse(response, context);
Expand Down

0 comments on commit eedfed2

Please sign in to comment.