Versions Compared

Key

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

...

The Business object CustomElementImpl.java represents the data model of the Hello World element. Since we want the author field to be persisted, we will add this property to this class. We define the property as an instance variable and add a getter and setter for it both in the interface and the implementation:

CustomElement.java

Code Block
themeEclipse

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

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

 

CustomElementImpl.java

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

...

  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 Metadata Field to the Media Item Version

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:

 

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

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:

...