|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.components.Component
org.apache.struts2.components.UIBean
org.apache.struts2.components.FormButton
org.apache.struts2.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:
<s:submit value="%{'Submit'}" />
Render an image submit: <s:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/>
Render an button submit: <s: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> <s:form id='theForm2' cssStyle="border: 1px solid green;" action='/AjaxRemoteForm.action' method='post' theme="ajax"> <input type='text' name='data' value='Struts User' /> <s:submit value="GO2" theme="ajax" resultDivId="two" /> </s: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:
<s:form id="frm1" action="newPersonWithXMLResult" theme="ajax" > <s:textfield label="Name" name="person.name" value="person.name" size="20" required="true" /> <s:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" notifyTopics="personUpdated, systemWorking" /> </s:form > <s:div href="/listPeople.action" theme="ajax" errorText="error opps" loadingText="loading..." id="cart-body" > <s:action namespace="" name="listPeople" executeResult="true" /> </s: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> <s:form id="frm1" action="newPersonWithXMLResult" theme="ajax" > <s:textfield label="Name" name="person.name" value="person.name" size="20" required="true" /> <s:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" onLoadJS="doGreatThings(data, type)" /> </s:form>
Field Summary | |
---|---|
protected java.lang.String |
listenTopics
|
protected java.lang.String |
notifyTopics
|
protected java.lang.String |
onLoadJS
|
protected java.lang.String |
preInvokeJS
|
protected java.lang.String |
resultDivId
|
protected java.lang.String |
src
|
static java.lang.String |
TEMPLATE
|
Fields inherited from class org.apache.struts2.components.FormButton |
---|
action, align, method, type |
Fields inherited from class org.apache.struts2.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 org.apache.struts2.components.Component |
---|
COMPONENT_STACK, id, parameters, stack |
Constructor Summary | |
---|---|
Submit(com.opensymphony.xwork2.util.OgnlValueStack stack,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
Method Summary | |
---|---|
void |
evaluateExtraParams()
|
void |
evaluateParams()
|
protected java.lang.String |
getDefaultTemplate()
A contract that requires each concrete UI Tag to specify which template should be used as a default. |
void |
setLabel(java.lang.String label)
Supply a submit button text apart from submit value. |
void |
setListenTopics(java.lang.String listenTopics)
Set listenTopics attribute. |
void |
setNotifyTopics(java.lang.String notifyTopics)
Topic names to post an event to after the form has been submitted. |
void |
setOnLoadJS(java.lang.String onLoadJS)
Javascript code that will be executed after the form has been submitted. |
void |
setPreInvokeJS(java.lang.String preInvokeJS)
Javascript code that will be executed before invokation. |
void |
setResultDivId(java.lang.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(java.lang.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 org.apache.struts2.components.FormButton |
---|
populateComponentHtmlId, setAction, setAlign, setMethod, setType |
Methods inherited from class org.apache.struts2.components.UIBean |
---|
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, escape, evaluateNameValue, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, setAccesskey, setCssClass, setCssStyle, setDisabled, 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 org.apache.struts2.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 java.lang.String TEMPLATE
protected java.lang.String resultDivId
protected java.lang.String onLoadJS
protected java.lang.String notifyTopics
protected java.lang.String listenTopics
protected java.lang.String preInvokeJS
protected java.lang.String src
Constructor Detail |
---|
public Submit(com.opensymphony.xwork2.util.OgnlValueStack stack, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Method Detail |
---|
protected java.lang.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(java.lang.String resultDivId)
public void setOnLoadJS(java.lang.String onLoadJS)
public void setNotifyTopics(java.lang.String notifyTopics)
public void setListenTopics(java.lang.String listenTopics)
public void setPreInvokeJS(java.lang.String preInvokeJS)
public void setLabel(java.lang.String label)
setLabel
in class UIBean
public void setSrc(java.lang.String src)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |