struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Musachy Barroso <mbarr...@wfscorp.com>
Subject Re: Still Ajax and Struts 2
Date Thu, 07 Dec 2006 21:01:09 GMT
I think you should take a look at the Struts2/Webwork tutorials 
http://www.opensymphony.com/webwork/wikidocs/Tutorial.html and 
http://struts.apache.org/2.x/docs/tutorials.html

If you look at the showcase code you will see this for the AjaxTest action:

in struts-ajax.xml:

<action name="AjaxTest" 
class="org.apache.struts2.showcase.ajax.AjaxTestAction">
    <result>/ajax/AjaxResult.jsp</result>
 </action>

in AjaxTestAction.java:

public class AjaxTestAction implements Action, Serializable {

    private static int counter = 0;
    private String data;

    public long getServerTime() {
        return System.currentTimeMillis();
    }

    public int getCount() {
        return ++counter;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String execute() throws Exception {
        return SUCCESS;
    }
}

and AjaxResult.jsp:

<%@ taglib prefix="s" uri="/struts-tags" %>

<%
    request.setAttribute("decorator", "none");
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the 
proxy server
%>

Result: <s:property value="count"/> @ <s:property value="serverTime"/>
<br/>
<s:property value="data"/>

musachy

walidito wrote:
> I,
> I wanna run this type of example app :
> http://www.planetstruts.org/struts2-showcase/viewSource.action?page=/ajax/remotediv/example1.jsp

> :
> <s:div
> 13:         id="once"
> 14:         theme="ajax"
> 15:         cssStyle="border: 1px solid yellow;"
> 16:         href="/AjaxTest.action"
> 17:         delay="5000"
> 18:         loadingText="loading...">
> 19:     Initial Content
> </s:div>
>
> In other word, a basic ajax component that allows a refreshment of only a
> part of my page.
>
> But I didn't get how to write the corresonding action and action mapping. 
> For the moment I've tried to put a "success" return in my action ( is it
> enough ?), but I don't see what to put in my action mapping (i mean inside
> the <action name="blablabla" ...> tag. If I put nothing, of course it's
> wrong.
> If I only put a success-type result, It creates an infinite loop (always
> displays "loading").
> Can sobdy help please?
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message