public class SimpleHTMLReportAction extends SimpleTemplaterAction implements IForwardAction
In most cases, you just have to call Objects.getEntityParameters(your_entity) and Objects.getCollectionParametersList(your_collection) in the action.
public class ReportProjectAction extends SimpleHtmlReportAction {
public Map<String, Object> getParameters() throws Exception {
Project p = (Project)MapFacade.findEntity(getModelName(), getView().getKeyValuesWithValue());
return getParameters(p);
}
public static Map<String, Object> getParameters(Project p) throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
// get all the field contents of the entity
parameters.putAll(Objects.getEntityParameters(p));
// get the field contents of the collections
parameters.put("milestones", Objects.getCollectionParametersList(p.getMilestones()));
parameters.put("actions", Objects.getCollectionParametersList(p.getActions()));
return parameters;
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">controllers.xml
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Project - ${reference}</title>
<link href="/OpenXavaTest/xava/style/report.css" rel="stylesheet" type="text/css">
</head>
<body>
<table>
<tr><td>Name:</td><td>${name}</td></tr>
<tr><td>Reference:</td><td>${reference}</td></tr>
<tr><td>Owner:</td><td>${owner.firstName} ${owner.lastName}</td></tr>
<!-- $$if(customers) -->
<tr><td>Customers:</td><td>${customer}</td></tr>
<!-- $$endif(customers) -->
</table>
<table>
<tr>
<td>Milestone</td>
<td>Target</td>
<td>Achieved</td>
</tr>
<!-- $$for(milestones) -->
<tr>
<td>${milestone.name}</td>
<td>${targetDate}</td>
<td>${achievedDate}</td>
</tr>
<!-- $$endfor(milestones) -->
</table>
</body>
</html>
<controller name="Project">Here we have used twice the same report action with 2 different templates for Project to report on different part of the entity.
<extends controller="Typical"/>
<action name="datasheet" image="images/report.gif" mode="detail"
class="org.openxava.actions.ReportProjectAction" >
<set property="template" value="/Project.html" />
</action>
<action name="actionsReport" image="images/report.gif" mode="detail"
class="org.openxava.actions.ReportProjectAction" >
<set property="template" value="/ProjectActions.html" />
</action>
</controller>
<controller name="Company">
<extends controller="Typical"/>
<action name="report" image="images/report.gif" mode="detail"
class="org.openxava.actions.SimpleHtmlReportAction" />
</controller>
<controller name="SimpleHtmlReport">
<action name="report" image="images/report.gif" mode="detail"
class="org.openxava.actions.SimpleHtmlReportAction" />
</controller>
COLLECTION, MAX_DEPTH
DETAIL, LIST, PREVIOUS_MODE, SPLIT
Constructor and Description |
---|
SimpleHTMLReportAction() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getForwardURI()
The URI to go.
|
boolean |
inNewWindow() |
execute, getClassParameters, getCollectionParametersList, getCollectionParametersList, getCollectionTable, getCollectionTable, getDepth, getEntityParameters, getEntityParameters, getEntityParameters, getFieldsTable, getParameters, getTemplate, getValuesTable, setDepth, setModel, setTemplate
getCollection, getRow, getSelected, getSelectedKeys, getTab, setCollection, setRow, setViewObject
closeDialog, getModelName, getPreviousView, getPreviousViews, getView, resetDescriptionsCache, returnToPreviousView, setControllers, setPreviousViews, setView, showDialog, showDialog, showNewView, showView, validateViewValues
addActions, addError, addErrors, addInfo, addMessage, addMessages, addWarning, clearActions, commit, executeAction, executeAfter, executeBefore, getContext, getEnvironment, getErrors, getLocale, getManager, getMessages, getNextMode, getQualifiedActionIfAvailable, getRequest, removeActions, returnToPreviousControllers, rollback, setContext, setDefaultControllers, setEnvironment, setErrors, setMessages, setNextMode, setRequest
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, getErrors, getMessages, setEnvironment, setErrors, setMessages
public java.lang.String getForwardURI()
IForwardAction
If it starts with "http://" or "https://" the action will forward to the absolute URL in internet (since v4m1). Since 4.0.1 if it starts with "javascript:" the corresponding code will executed by the browser. Since 5.9 you should use IJavaScriptPostAction to execute JavaScript because IForwardAction with javascript: does not update the page before executing the JavaScript, but executes the JavaScript instead. If it returns null the forwarding is not done.
getForwardURI
in interface IForwardAction
public boolean inNewWindow()
inNewWindow
in interface IForwardAction