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

Unterschiede anzeigen Seitenhistorie anzeigen

Version 1 Nächste Version anzeigen »


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, ...).
Unable to render embedded object: File (worddave6290d961dc319b85aba0adbde617440.png) not found.
To handle a save request on your own, just overwrite the method saveDOM().
<span style="color: #7f0055"><strong>public</strong></span> ResultObject saveDOM() {
ResultObject result = <span style="color: #7f0055"><strong>new</strong></span> ResultObject();
String category = ResultObject.<span style="color: #0000c0"><em>OK</em></span>;
String statusMessage = <span style="color: #7f0055"><strong>null</strong></span>;
String xmlIdentifier = <span style="color: #7f0055"><strong>null</strong></span>;
<span style="color: #7f0055"><strong>if</strong></span> (getDOMHandler().getXMLIdentification().<span style="color: #0000c0">length</span> > 0) {
xmlIdentifier = getDOMHandler().getXMLIdentification()[0];
}
<span style="color: #7f0055"><strong>try</strong></span> {
String xml = getDOM().serialize().toString(); <span style="color: #3f7f5f">//store this xml to your DB as an example</span>
statusMessage = <span style="color: #2a00ff">"Document has been stored successfully"</span>;
} <span style="color: #7f0055"><strong>catch</strong></span> (ValidationException e) {
category = ResultObject.<span style="color: #0000c0"><em>ERROR</em></span>;
statusMessage = <span style="color: #2a00ff">"Failed to save. Reason: "</span> + e.getLocalizedMessage();
}
setClientStatusBarMessage((HttpServletRequest)getDOM().getClientProperty(<span style="color: #2a00ff">"http-request"</span>), getDOM(),result, category, statusMessage, <span style="color: #7f0055"><strong>null</strong></span>);
<span style="color: #7f0055"><strong>return</strong></span> result;
}

Unable to render embedded object: File (worddave6290d961dc319b85aba0adbde617440.png) not found. 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.
<span style="color: #7f0055"><strong>public</strong></span> 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>


Unable to render embedded object: File (worddave6290d961dc319b85aba0adbde617440.png) not found. To interact with the button clicked on your web form, just implement the method performUserAction().
<span style="color: #7f0055"><strong>public</strong></span> ResultObject performUserAction(HttpServletRequest request, HttpServletResponse response, String actionName) {
ResultObject result = <span style="color: #7f0055"><strong>new</strong></span> ResultObject();
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #2a00ff">"ownAction1"</span>.equals(actionName)) {
StringBuffer htmlResponse = <span style="color: #7f0055"><strong>new</strong></span> StringBuffer();
htmlResponse.append(<span style="color: #2a00ff">"<br/>"</span>);
htmlResponse.append(<span style="color: #2a00ff">"<b>Hello...</span>
result.setObject(htmlResponse);
} <span style="color: #7f0055"><strong>else</strong></span> <span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #2a00ff">"ownAction2"</span>.equals(actionName)) {
StringBuffer htmlResponse = <span style="color: #7f0055"><strong>new</strong></span> StringBuffer();
htmlResponse.append(<span style="color: #2a00ff">"<br/><br/><br/>"</span>);
htmlResponse.append(<span style="color: #2a00ff">"<b>Hello JAXFront user...</span>
result.setObject(htmlResponse);
} <span style="color: #7f0055"><strong>else</strong></span> <span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #2a00ff">"forwardToJSPAction"</span>.equals(actionName)) {
RequestDispatcher dispatcher = request.getRequestDispatcher(<span style="color: #2a00ff">"/examples/purchaseOrder/hello.jsp"</span>);
<span style="color: #7f0055"><strong>try</strong></span> {
dispatcher.forward(request, response);
} <span style="color: #7f0055"><strong>catch</strong></span> (Exception e) {}
result.setDispatched();
} <span style="color: #7f0055"><strong>else</strong></span> {
result = <span style="color: #7f0055"><strong>super</strong></span>.performUserAction(request, response, actionName);
}
<span style="color: #7f0055"><strong>return</strong></span> 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