I use the WMD label editor in a project for a large number of fields that correspond to a large number of properties in a large number of Entity classes. Some classes may have several markdown properties.
I keep markdowns as it makes editing fields easier later. However, I need to convert the properties to HTML for display later. The question is: is there some kind of template that I can use to avoid writing markdown conversion code in all my entity classes?
I created a utility class with a method that takes a markdown string and returns HTML. I am using markdownj and it works fine.
The problem is every property of every class that stores markdowns. I may need another method that converts to HTML:
public class Course{
private String description;
.
.
.
public String getDescription(){
return description;
}
public String getDescriptionAsHTML(){
return MarkdownUtil.convert(getDescription());
}
.
.
.
}
The problem is that if the Course class has 2 more properties, then regarding learning requirements and prerequisites, both require converters, then I will have to write getTuitionAsHTML () and getPrerequisiteAsHTML ().
I find this a bit ugly and would like a cleaner solution. Classes that require this are not part of a single inheritance hierarchy.
Another option that I am considering is doing this in the controller, not in the model. What do you think about this?
Thank.
[EDIT]: ( ). struts2 ( ), , , . , HTML.