Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'target' Binding to ERAttachmentLink #362

Merged
merged 3 commits into from
Jan 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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