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

New ERMD2WUserPresentableDescriptionHeader #762

Merged
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
@@ -0,0 +1 @@
<webobject name = "ShowHeading"><h1 class="PageHeader"><webobject name = "HeadingString" /></h1></webobject>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
HeadingString : WOString {
value = headerString;
escapeHTML = d2wContext.escapeHTML;
}

ShowHeading : WOConditional {
condition = showHeading;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"WebObjects Release" = "WebObjects 5.0";
encoding = "UTF-8";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package er.modern.directtoweb.components.header;

import com.webobjects.appserver.WOContext;
import com.webobjects.eocontrol.EOEnterpriseObject;

import er.extensions.foundation.ERXStringUtilities;
import er.modern.directtoweb.components.header.ERMD2WHeader;
import er.modern.directtoweb.components.header.ERMD2WSimpleHeader;

/**
* Simple h1 header that defaults to displaying the
* displayNameForPageConfiguration and appends the object's
* userPresentableDescription if one is available.
*
* @author fpeters
*
*/
public class ERMD2WUserPresentableDescriptionHeader extends ERMD2WSimpleHeader {

private static final long serialVersionUID = 1L;

public interface Keys extends ERMD2WHeader.Keys {
public static String displayNameForPageConfiguration = "displayNameForPageConfiguration";
}

protected String _headerString;

public ERMD2WUserPresentableDescriptionHeader(WOContext context) {
super(context);
}

public String headerString() {
String headerString = super.headerString();
if (object() != null) {
String userPresentableDescription = (String) object().valueForKey(
"userPresentableDescription");
if (!ERXStringUtilities.stringIsNullOrEmpty(userPresentableDescription)) {
// is displayNameForPageConfiguration null?
if (ERXStringUtilities.stringIsNullOrEmpty(headerString)) {
headerString = userPresentableDescription;
} else {
headerString = headerString + ": " + userPresentableDescription;
}
}
}
return headerString;
}

public EOEnterpriseObject object() {
EOEnterpriseObject _object = (EOEnterpriseObject) valueForBinding("object");
return _object;
}

}