|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.webwork.components.Component
com.opensymphony.webwork.components.UIBean
com.opensymphony.webwork.components.FormButton
com.opensymphony.webwork.components.Submit
public class Submit
Render a submit button. The submit tag is used together with the form tag to provide asynchronous form submissions. The submit can have three different types of rendering:
<ww:submit value="%{'Submit'}" />
Render an image submit: <ww:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/>
Render an button submit: <ww:submit type="button" value="%{'Submit'}" label="Submit the form"/>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED
Remote form replacing another div: <div id='two' style="border: 1px solid yellow;">Initial content</div> <ww:form id='theForm2' cssStyle="border: 1px solid green;" action='/AjaxRemoteForm.action' method='post' theme="ajax"> <input type='text' name='data' value='WebWork User' /> <ww:submit value="GO2" theme="ajax" resultDivId="two" /> </ww:form >Notify other controls(divs) of a change. Using an pub-sub model you can notify others that your control changed and they can take the appropriate action. Most likely they will execute some action to refresh. The notifyTopics does this for you. You can have many topic names in a comma delimited list. eg: notifyTopics="newPerson, dataChanged" . Here is an example of this approach:
<ww:form id="frm1" action="newPersonWithXMLResult" theme="ajax" > <ww:textfield label="Name" name="person.name" value="person.name" size="20" required="true" /> <ww:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" notifyTopics="personUpdated, systemWorking" /> </ww:form > <ww:div href="/listPeople.action" theme="ajax" errorText="error opps" loadingText="loading..." id="cart-body" > <ww:action namespace="" name="listPeople" executeResult="true" /> </ww:div>Massage the results with JavaScript. Say that your result returns some h appy XML and you want to parse it and do lots of cool things with it. The way to do this is with a onLoadJS handler. Here you provide the name of a JavaScript function to be called back with the result and the event type. The only key is that you must use the variable names 'data' and 'type' when defining the callback. For example: onLoadJS="myFancyDancyFunction(data, type)". While I talked about XML in this example, your not limited to XML, the data in the callback will be exactly whats returned as your result. Here is an example of this approach:
<script language="JavaScript" type="text/javascript"> function doGreatThings(data, type) { //Do whatever with your returned fragment... //Perhapps.... if xml... var xml = dojo.xml.domUtil.createDocumentFromText(data); var people = xml.getElementsByTagName("person"); for(var i = 0;i < people.length; i ++){ var person = people[i]; var name = person.getAttribute("name") var id = person.getAttribute("id") alert('Thanks dude. Person: ' + name + ' saved great!!!'); } } </script> <ww:form id="frm1" action="newPersonWithXMLResult" theme="ajax" > <ww:textfield label="Name" name="person.name" value="person.name" size="20" required="true" /> <ww:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" onLoadJS="doGreatThings(data, type)" /> </ww:form>
Field Summary | |
---|---|
protected String |
listenTopics
|
protected String |
notifyTopics
|
protected String |
onLoadJS
|
protected String |
preInvokeJS
|
protected String |
resultDivId
|
protected String |
src
|
static String |
TEMPLATE
|
Fields inherited from class com.opensymphony.webwork.components.FormButton |
---|
action, align, method, type |
Fields inherited from class com.opensymphony.webwork.components.UIBean |
---|
accesskey, cssClass, cssStyle, disabled, label, labelPosition, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, required, requiredposition, response, tabindex, template, templateDir, templateSuffix, theme, title, tooltip, tooltipConfig, value |
Fields inherited from class com.opensymphony.webwork.components.Component |
---|
COMPONENT_STACK, id, parameters, stack |
Constructor Summary | |
---|---|
Submit(OgnlValueStack stack,
HttpServletRequest request,
HttpServletResponse response)
|
Method Summary | |
---|---|
void |
evaluateExtraParams()
|
void |
evaluateParams()
|
protected String |
getDefaultTemplate()
A contract that requires each concrete UI Tag to specify which template should be used as a default. |
void |
setLabel(String label)
Supply a submit button text apart from submit value. |
void |
setListenTopics(String listenTopics)
Set listenTopics attribute. |
void |
setNotifyTopics(String notifyTopics)
Topic names to post an event to after the form has been submitted. |
void |
setOnLoadJS(String onLoadJS)
Javascript code that will be executed after the form has been submitted. |
void |
setPreInvokeJS(String preInvokeJS)
Javascript code that will be executed before invokation. |
void |
setResultDivId(String resultDivId)
The id of the HTML element to place the result (this can the the form's id or any id on the page. |
void |
setSrc(String src)
Supply an image src for image type submit button. |
protected boolean |
supportsImageType()
Indicate whether the concrete button supports the type "image". |
Methods inherited from class com.opensymphony.webwork.components.FormButton |
---|
populateComponentHtmlId, setAction, setAlign, setMethod, setType |
Methods inherited from class com.opensymphony.webwork.components.UIBean |
---|
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, escape, evaluateNameValue, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, setAccesskey, setCssClass, setCssStyle, setDisabled, setLabelposition, setLabelPosition, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequired, setRequiredposition, setTabindex, setTemplate, setTemplateDir, setTheme, setTitle, setTooltip, setTooltipConfig, setValue |
Methods inherited from class com.opensymphony.webwork.components.Component |
---|
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setId, start, toString, usesBody |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TEMPLATE
protected String resultDivId
protected String onLoadJS
protected String notifyTopics
protected String listenTopics
protected String preInvokeJS
protected String src
Constructor Detail |
---|
public Submit(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response)
Method Detail |
---|
protected String getDefaultTemplate()
UIBean
getDefaultTemplate
in class UIBean
public void evaluateParams()
evaluateParams
in class UIBean
public void evaluateExtraParams()
evaluateExtraParams
in class FormButton
protected boolean supportsImageType()
supportsImageType
in class FormButton
public void setResultDivId(String resultDivId)
public void setOnLoadJS(String onLoadJS)
public void setNotifyTopics(String notifyTopics)
public void setListenTopics(String listenTopics)
public void setPreInvokeJS(String preInvokeJS)
public void setLabel(String label)
setLabel
in class UIBean
public void setSrc(String src)
|
WebWork Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |