struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
Date Wed, 20 Feb 2008 23:14:04 GMT
View the html source in the browser.

The head should contain a script like this one from the struts2-showcase:

<script type="text/javascript">
    // Dojo configuration
    djConfig = {
        baseRelativePath: "/struts2-showcase/struts/dojo",
        isDebug: false,
        bindEncoding: "UTF-8",
        debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with
the includes
    };
</script>
<script type="text/javascript"
        src="/struts2-showcase/struts/dojo/dojo.js"></script>
<script type="text/javascript"
        src="/struts2-showcase/struts/simple/dojoRequire.js"></script>

<script type="text/javascript"
        src="/struts2-showcase/struts/ajax/dojoRequire.js"></script>
<script type="text/javascript"
        src="/struts2-showcase/struts/CommonFunctions.js"></script>


In FireBug, you should see all those scripts being found.

xianwinwin wrote:
>
> "Check that dojo is setup in the head of your page (view the html)"
> how do I do that?
>
> Thank you!
>
>
> Jeromy Evans - Blue Sky Minds wrote:
>   
>> Use the FireBug plugin for FF.
>>
>> Check that dojo is setup in the head of your page (view the html) and 
>> that all of the resources it requires are loaded (using the net tab). 
>> Ensure that struts filter is receiving requests for the /struts/*
>> resources.
>>
>> xianwinwin wrote:
>>     
>>> :-( 
>>> I think I have an issue with the ajax configuration (I'm not sure).
>>> How can I verify that my theme="ajax" is configured properly?
>>>
>>> thank you!
>>>
>>>
>>>
>>>
>>>
>>> Jeromy Evans - Blue Sky Minds wrote:
>>>   
>>>       
>>>> No, it seems fine now.
>>>>
>>>> Turn on debugging:
>>>>
>>>> <s:head theme="ajax" debug="true/>
>>>>
>>>> Also use FireBug to see if there's any javascript errors reported.
>>>>
>>>>
>>>> xianwinwin wrote:
>>>>     
>>>>         
>>>>> thanks you for the reply. I added the code:
>>>>>
>>>>>     <s:head theme="ajax"/>
>>>>>
>>>>> on top, plus
>>>>>
>>>>> <s:submit value="GO2" showLoadingText="false"  theme="ajax"
>>>>> targets="two"
>>>>> />
>>>>>
>>>>> but I get the same result - it goes to an empty page with the result
>>>>> and
>>>>> not
>>>>> to the DIV?
>>>>> :-(
>>>>>
>>>>> any idea?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> xianwinwin wrote:
>>>>>   
>>>>>       
>>>>>           
>>>>>> Hi all,
>>>>>> I'm trying to return a result to DIV in a form (in the example
>>>>>> id='two')
>>>>>>
>>>>>> this is my form:
>>>>>>
>>>>>> <div id='two' style="border: 1px solid yellow;">initial content</div>
>>>>>> <s:form
>>>>>>         id='theForm2'
>>>>>>         cssStyle="border: 1px solid green;"
>>>>>>         action='testing_AjaxRemoteForm'
>>>>>>         method='post'
>>>>>>         theme="ajax">
>>>>>>
>>>>>>     <input type='text' name='data' value='Struts User'>
>>>>>>
>>>>>>     <s:submit value="GO2" theme="ajax" targets="theForm2"/>
>>>>>>
>>>>>> </s:form>
>>>>>>
>>>>>> when the user clicks the GO2 --> the action, AjaxRemoteForm, 
is
>>>>>> 'activated' (showing the 'data' the user has input)
>>>>>>
>>>>>> 	public String AjaxRemoteForm()
>>>>>> 	{
>>>>>> 		System.out.println("active ajax test 1 with data: "+data);
>>>>>> 		return "test.ajax.2";
>>>>>> 	}
>>>>>>
>>>>>> and routed to AjaxResult3.jsp:
>>>>>>
>>>>>>         <action name="testing_*"  method="{1}"
>>>>>> class="com.struts.user.account.TestingAction">			
>>>>>> 			<result name="test.1" 			type="tiles">test_1</result>
>>>>>> 			<result name="test.ajax.2">/pages/welcome/AjaxResult3.jsp</result>
>>>>>>             <interceptor-ref name="user"/>
>>>>>>         </action>
>>>>>>
>>>>>>
>>>>>>
>>>>>> The result comes in a NEW page with the 'data' value the user has
>>>>>> input
>>>>>>
>>>>>>
>>>>>>
>>>>>> "AjaxResult3.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
>>>>>> %>
>>>>>>
>>>>>> The value you entered was: <s:property value="data"/><br/>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Q: How can I incorporate the 'data' value in the DIV and not in a
new
>>>>>> page?
>>>>>>
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>   
>>>>>       
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>     
>
>   

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


Mime
View raw message