Sie zeigen eine alte Version dieser Seite an. Zeigen Sie die aktuelle Version an.

Unterschiede anzeigen Seitenhistorie anzeigen

« Vorherige Version anzeigen Version 2 Aktuelle »


The DOMActionController (i.e. MyOwnDOMActionController class) let you interact with the generated web form. You may even define your own web form buttons to interacte with the form (save, validate, print, ...).

To handle a save request on your own, just overwrite the method saveDOM().
public ResultObject saveDOM() {
ResultObject result = new ResultObject();
String category = ResultObject.OK;
String statusMessage = null;
String xmlIdentifier = null;
if (getDOMHandler().getXMLIdentification().length > 0) {
xmlIdentifier = getDOMHandler().getXMLIdentification()[0];
}
try {
String xml = getDOM().serialize().toString(); //store this xml to your DB as an example
statusMessage = "Document has been stored successfully";
} catch (ValidationException e) {
category = ResultObject.ERROR;
statusMessage = "Failed to save. Reason: " + e.getLocalizedMessage();
}
setClientStatusBarMessage((HttpServletRequest)getDOM().getClientProperty("http-request"), getDOM(),result, category, statusMessage, null);
return result;
}

If you want to have your own buttons on top of your form, just overwrite the method getHTMLButtonControls(). If you do not overwrite, the button defined in the template "ControlFrame.html" will be taken.
public String getHTMLButtonControls(HttpServletRequest request) {
//return an xhtml string defining your form buttons
}
To call a specific user action in your own ActionController, an action can be called wherever in your HTML web frontend by calling one of the following javascripts:
a) without any return value (return null), performUserAction('actionName')
b) with a return value (return anObject), performUserActionWithPopUp('actionName')
Option b) will open a dialog window with the content of the passed Object.
The following html snippets shows how to call an own action.
<button id= "button_ownAction1" name="test" type="button" onclick="performUserActionWithResponseDIV(this,'ownAction1', null, 'DIV_CUSTOM_AREA',null);">
<p><img src="${IMAGE_BASE}hint_16x16.gif"/> <b>own action 1</b> </p>
</button>


To interact with the button clicked on your web form, just implement the method performUserAction().
public ResultObject performUserAction(HttpServletRequest request, HttpServletResponse response, String actionName) {
ResultObject result = new ResultObject();
if ("ownAction1".equals(actionName)) {
StringBuffer htmlResponse = new StringBuffer();
htmlResponse.append("<br/>");
htmlResponse.append("<b>Hello...
result.setObject(htmlResponse);
} else if ("ownAction2".equals(actionName)) {
StringBuffer htmlResponse = new StringBuffer();
htmlResponse.append("<br/><br/><br/>");
htmlResponse.append("<b>Hello JAXFront user...
result.setObject(htmlResponse);
} else if ("forwardToJSPAction".equals(actionName)) {
RequestDispatcher dispatcher = request.getRequestDispatcher("/examples/purchaseOrder/hello.jsp");
try {
dispatcher.forward(request, response);
} catch (Exception e) {}
result.setDispatched();
} else {
result = super.performUserAction(request, response, actionName);
}
return result;
}

The action name (i.e. "ownAction1") gets passed to the current DOM action controller. The action controller can implement the action. Each action is identified by a unique action name.
Be sure that the correct mime type for the returned object has been registered before. To register a mime type for an own user action, call the following method on class "JAXFrontServlet":
JAXFrontServlet.registerMimeTypeMapping("actionName", "mimeType");







  • Keine Stichwörter