You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2007/11/01 05:42:51 UTC

Re: struts 1.2: calling an action by ajax (javawebparts)

I would suggest joining the JWP mailing list and re-posting this 
question there... the form manipulator handler was written by a member 
of the JWP team named Herman, and I know he'd be able to help you out 
quickly.  I think though that there is an example of that handler in the 
JWP sample application that comes with the distribution, if memory 
serves, you may want to check that out first.  If it's no help, moving 
to the JWP mailing list would probably be a good idea at this point 
since this isn't so much Struts-related any more.

Frank

Ingo Villnow wrote:
> I referred to the manual and there it suggested to use "parameter"
> instead, like this:
> 
> <requestHandler type="std:QueryString"
> target="/ajax.do">
> <parameter>value=name</parameter>
> </requestHandler>
> 
> then you can use: String value = (String) request.getParameter("value");
> 
> Now i have another problem :-)) I want to use the "std:FormManipulator"
> als ResponseHandler, but I have problems with the correct
> XML-Response-Format and i don't find any code example for that.
> I am generating the form by using the struts-tags <html:form>,<html:txt>
> and so on. And with the FormManipulator i think i can manipulate the
> generated form.
> 
> The other way maybe is that i generate my form like <html type="text"
> value="<% ..... %>" after the <ajax:event> called my action and my
> action puts me a bean into the request.
> 
> Greetings, Ingo
> 
> 
> Frank W. Zammetti schrieb:
>> Can you tell where that error is coming from?  I don't recognize it as
>> an APT error, so I'm guessing Struts, but I don't recall ever seeing
>> that before.
>>
>> You know what... what happens if you remove the <?xml> and <!DOCTYPE>
>> tags?  Does it work then?
>>
>> Frank
>>
>> Ingo Villnow wrote:
>>> ok, the Text in the index-result is working now, but i want to use the
>>> actions and when i use parameters like
>>> "/employee.do?task=update&ajax=getEmployee" then there comes an error
>>> message "The reference to entity "ajax" must end with the ';'
>>> delimiter."
>>>
>>> Ingo Villnow schrieb:
>>>> Hello,
>>>>
>>>> now i am using the javawebparts.ajaxparts and when i put all the things
>>>> in a whole jsp-site, than the ajax is working:
>>>>
>>>> <%@ taglib prefix="ajax" uri="javawebparts/ajaxparts/taglib" %>
>>>> <?xml version="1.0" encoding="ISO-8859-1" ?>
>>>> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
>>>>     pageEncoding="ISO-8859-1"%>
>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>>> <head>
>>>> <meta http-equiv="Content-Type" content="text/html;
>>>> charset=ISO-8859-1" />
>>>> <title>Insert title here</title>
>>>> </head>
>>>> <body>
>>>> <form action="#">
>>>> <input id="btn" type="button" value="TESTBUTTON"/><ajax:event
>>>> ajaxRef="employee/update" attachTo="btn"/>
>>>> </form>
>>>> <div id="result-div">
>>>>
>>>> </div>
>>>> <ajax:enable/>
>>>> </body>
>>>> </html>
>>>>
>>>> But when i am using it with struts-tiles than it doesn't work :-( - i
>>>> think that's because the target in the ajax-config is not found. I
>>>> don't
>>>> now why. Without tiles, the target
>>>> will be found. The index-result.txt is in the same directory as the
>>>> jsp-site.
>>>>
>>>> <ajaxConfig>
>>>>     <group ajaxRef="employee">
>>>>         <element ajaxRef="update">
>>>>             <event type="onclick">
>>>>                 <requestHandler type="std:SimpleRequest"
>>>>                     target="index-result.txt">
>>>>                     <parameter />
>>>>                 </requestHandler>
>>>>                 <responseHandler type="std:InnerHTML">
>>>>                     <parameter>result-div</parameter>
>>>>                 </responseHandler>
>>>>             </event>
>>>>         </element>
>>>>     </group>
>>>> </ajaxConfig>
>>>>
>>>> When i use an action as a target, it doesn't work, too (e.g.
>>>> target="action.do?parameter=xxx&param2=yyy). I use the DispatchAction,
>>>> so with the parameter I can delegate or specifiy the method, which will
>>>> be called in my action...
>>>>
>>>> Any ideas?
>>>>
>>>> Thank's a lot!!
>>>>
>>>> Greetings from Berlin
>>>>
>>>>
>>>> Frank W. Zammetti schrieb:
>>>>  
>>>>> I should also point out the presentation Ted Husted did at The Ajax
>>>>> Experience last week which dealt largely with APT.  The slides for
>>>>> that
>>>>> presentation are here:
>>>>>
>>>>> http://ajaxexperience.techtarget.com/images/Presentations/Husted_Ted_RetrofittingStruts.pdf
>>>>>
>>>>>
>>>>> I'm not quite sure how long they will stay posted there though, so
>>>>> get it
>>>>> while it's hot :)
>>>>>
>>>>> Frank
>>>>>
>>>>> On Wed, October 31, 2007 10:48 am, Frank W. Zammetti wrote:
>>>>>      
>>>>>> On Wed, October 31, 2007 10:19 am, Ingo Villnow wrote:
>>>>>>          
>>>>>>> i want to call an action by javascript, when a value in a
>>>>>>> <html:select>
>>>>>>> field changes. I want to fill my <html:form> with the data
>>>>>>> provided by
>>>>>>> the action. Any ideas? I don't know a lot of javascript :-(
>>>>>>>               
>>>>>> There's a couple if ways you could do that... one would be to call
>>>>>> the
>>>>>> submit() method of the form object, which every form in HTML has,
>>>>>> then
>>>>>> re-render the page with the updated data in the form.  That's of
>>>>>> course
>>>>>> going to refresh the entire page, which I suspect isn't what you
>>>>>> want.
>>>>>>
>>>>>> So, AJAX is probably what you want.  Now, how you go about doing
>>>>>> that,
>>>>>> well, there's a few hundred options :)  Because you don't know a
>>>>>> lot of
>>>>>> Javascript, you might want to consider the AjaxParts Taglib (APT)
>>>>>> from
>>>>>> Java Web Parts (JWP):
>>>>>>
>>>>>> http://javawebparts.sourceforge.net
>>>>>>
>>>>>> Direct to APT:
>>>>>>
>>>>>> http://javawebparts.sourceforge.net/javadocs/javawebparts/ajaxparts/taglib/package-summary.html
>>>>>>
>>>>>>
>>>>>> If you go to the download page, the cookbook has some examples
>>>>>> that are
>>>>>> very much along the lines of what you're asking for.  If you go that
>>>>>> route, we'll be more than happy on the JWP mailing list, or forums.
>>>>>>
>>>>>> Otherwise, prototype (http://www.prototypejs.org) is a good, simple
>>>>>> option, but you will be writing some Javascript.
>>>>>>
>>>>>>          
>>>>>>> thanks & greetings from Berlin
>>>>>>>               
>>>>>> hth,
>>>>>> Frank
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> 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
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition. Version: 7.5.503 / Virus Database:
>>> 269.15.14/1100 - Release Date: 10/30/2007 6:26 PM
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.503 / Virus Database: 269.15.14/1100 - Release Date: 10/30/2007 6:26 PM

-- 
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
  (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
  (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
  Supplying the wheel, so you don't have to reinvent it!

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