In this section, you will learn about the div tag. The div tag is an Ajax component that is used with Ajax that refreshes the content of a particular section without refreshing the entire page.
In this section, you will learn about the div tag. The div tag is an Ajax component that is used with Ajax that refreshes the content of a particular section without refreshing the entire page.In this section, you will learn about the div tag. The div tag is an Ajax component that is used with Ajax that refreshes the content of a particular section without refreshing the entire page.
The div tag when used with Ajax refreshes the content of a particular section without refreshing the entire page.
HTML <DIV /> tag created by Ajax div tag includes it's content and is used to obtain it's content through a remote XMLHttpRequest call through the dojo framework.
THE FOLLOWING ATTRIBUTES ARE VALID IF AJAX IS CONFIGURED
The attribute 'updateFreq' refreshes after a certain time period, specified in miliseconds.
The attribute 'autoStart' starts the timer automatically while sets to true which is the default value.
The attribute 'startTimerListenTopics' is used to start the timer whenever 'startTimerListenTopic' is the comma-separated list of topics.
The attribute ''stopTimerListenTopics' is used to start the timer whenever ''stopTimerListenTopics' is the comma-separated list of topics.
'showLoadingText' displays the loaded text on targets while 'separateScript' runs each script in each scope that is unique for each Div.
Add the following code snippet into the struts.xml
file.
strurts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- Rose India Struts 2 Tutorials --> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <include file="struts-default.xml"/> <!-- Add packages here --> <package name="roseindia" namespace="/roseindia" extends="struts-default"> <action name="div"> <result>/pages/div.jsp</result> </action> </package> </struts> |
Create a jsp using the tag <s:div>.
div.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
|
mask.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Enter first and last name</title> <s:head theme="ajax" debug="false"/> </head> <body> <s:div id="maskValue" > <div style="position:absolute;top:10; left:20; width:300; height:175;background-color:#E5E5E5;"> <h3>Enter first and last name:</h3> <s:form theme="ajax" action="doMask"> <s:textfield name="firstname" label="Firstname" /> <s:textfield name="lastname" label="Lastname" /> <s:submit value="Submit" theme="ajax" targets="maskValue" /> </s:form> </div> <br> <div id="8" style="position:absolute;top:10; left:350; width:300; height:160;background-color:#E5E5E5;"> <h3>Output: </h3> Firstname : <s:property value="firstname" /> <br><br> Lastname : <s:property value="lastname" /> </div> </s:div> </body> </html> |
Output:
Ads