Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
/**
 * Returns the author of the custom element.
 * @return the author of the custom element
 */
String getAuthor();

/**
 * Sets the author of the custom element.
 * @param nameauthor the author of the custom element to set
 */
void setAuthor(String author);

...

Code Block
themeEclipse
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="wmedit" uri="http://www.gx.nl/taglib/wmedit"%>

...

  1. Add the property to the Media item version interface (CustomMediaItemVersion.java).
  2. Add the property to the Media item version (CustomMediaItemVersionImpl.java).
  3. Add the property to the form backing object (CustomMediaItemVersionFBO.java).
  4. Add a label to the language files to translate “Author” in the supported languages.
  5. Add the field to the edit JSP (editMetadata.jspf).


Adding a

...

Property to the

...

Business Object

The Business object "CustomMediaItemVersion" represents the data model of the HelloWorld media item. Since we want the author metadata field to be persisted we add this property to this class. We define the property as instance variable and add a getter and setter for it:

CustomMediaItemVersion.java

Code Block
themeEclipse
@Property
public String getAuthor() {
	return JcrUtil.getString(getPrivateNode(), "myJcrPrefix:author");
}

public void setAuthor(String author) {
	JcrUtil.setString(getPrivateNode(),"myJcrPrefix:author", author);
}

Adding a Metadata Field to the Media Item Version

/**
 * Returns the author of the custom media item.
 * @return the author of the custom media item
 */
String getAuthor();
 
/**
 * Sets the author of the custom media item.
 * @param name the author of the custom media item to set
 */
void setAuthor(String author);


CustomMediaItemVersionImpl.java The Business object CustomMediaItemVersionImpl.java represents the data model of the HelloWorld media item. Since we want the author metadata field to be persisted we add this property to this class. We define the property as instance variable and add a getter and setter for it:

Code Block
themeEclipse
@Property
public String getAuthor() {
	return JcrUtil.getString(getPrivateNode(), WCBConstants.NAMESPACE_PREFIX + "myJcrPrefix:author");
}

public void setAuthor(String author) {
	JcrUtil.setString(getPrivateNode(),"myJcrPrefix WCBConstants.NAMESPACE_PREFIX + ":author", author);
}


Since the Author also must be editable in the Editor, we also add the metadata field to the Form backing object of the metadata part (CustomMediaItemVersionFBO.java). This is done in a similar way as we did it for the business object:

...

See Adding a Language Label for a complete description of adding language labels. The following snippet should be added to each language file: When adding language labels, be sure that they conform to the Plugin Development Guidelines (G027 and G028 in particular).

...