Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> Ajax programming with Struts 2

Pages: 1
Anton Bashmakov
Unregistered




Implementing problems!
      #52390 - 08/28/07 02:29 PM

This article seems good, but I saw some mistakes. First of all there is no symbol "-" in xml tag names. I see extends="jsondefault", but it must be extends="json-default"! I've tried to implement this code, but I get JS error like "servise.methodName() is not a method" It's very sad.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anton Bashmakov
Unregistered




Re: Implementing problems! [Re: Anton Bashmakov]
      #52391 - 08/28/07 02:53 PM

I made it! It works.
1) Execute method of action must return SUCCESS
2) extends="jsondefault" must be extends="json-default"
3) interceptorref must be interceptor-ref
And every thing works fine.


Post Extras: Print Post   Remind Me!   Notify Moderator  
AthenAdministrator
journeyman


Reged: 06/05/07
Posts: 79
Loc: San Francisco, CA
Re: Implementing problems! [Re: Anton Bashmakov]
      #52397 - 08/28/07 05:39 PM

Thank you for your observations and quick workaround. I'll check in with the author and make the changes in the article itself if he agrees.

--------------------
Athen O'Shea
Editor, JavaWorld.com


Post Extras: Print Post   Remind Me!   Notify Moderator  
Oleg Mikheev
Unregistered




Re: Implementing problems! [Re: Anton Bashmakov]
      #52439 - 08/29/07 01:46 PM

Anton,

Thanks for your comments, they are mostly correct.
Dashes disappeared during editorial process, we will put them back asap.
But, why did you have to extend Action execute method? The default one returns SUCCESS already, doesn't it?

Oleg


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anton Bashmakov
Unregistered




Re: Implementing problems! [Re: Oleg Mikheev]
      #52765 - 09/03/07 09:10 AM

Yes it is. But it was not in my case. So maybe be you can tell me, Oleg, I have problem with dojo and Struts 2, I know that Dojo is bundled with Struts 2, but I can't do this on my JSP :
dojo.require("dojo.widget.Tree");
it fails and I have this in my js console :
djConfig.baseScriptUri has no properties.
I have <s:head theme="ajax" debug="true"/> on my jsp and suppose that dojo is turned on, but importing Tree widget fails while importing of, say, io.* or rpc.* packages is OK.
I need to copy dojo scr's into my application
and link jsp to it directly like this :
<script type="text/javascript">
var djConfig = { isDebug: true };
</script>
<script type="text/javascript" src="org/apache/struts2/static/dojo/dojo.js">/*_*/</script>
But I suppose this is not the way as I allready have dojo src's in struts 2 library, and this will not work if there is already <s:head theme="ajax" debug="true"/> defined on the page. What I did wrong?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anton_Bashmakov
stranger


Reged: 09/03/07
Posts: 2
Re: Implementing problems! [Re: Oleg Mikheev]
      #52766 - 09/03/07 09:18 AM


Yes it is. But it was not in my case. So maybe be you can tell me, Oleg, I have problem with dojo and Struts 2, I know that Dojo is bundled with Struts 2, but I can't do this on my JSP :
dojo.require("dojo.widget.Tree");
it fails and I have this in my js console :
djConfig.baseScriptUri has no properties.
I have <s:head theme="ajax" debug="true"/> on my jsp and suppose that dojo is turned on, but importing Tree widget fails while importing of, say, io.* or rpc.* packages is OK.
I need to copy dojo scr's into my application
and link jsp to it directly like this :
<script type="text/javascript">
var djConfig = { isDebug: true };
</script>
<script type="text/javascript" src="org/apache/struts2/static/dojo/dojo.js">/*_*/</script>
But I suppose this is not the way as I allready have dojo src's in struts 2 library, and this will not work if there is already <s:head theme="ajax" debug="true"/> defined on the page. What I did wrong?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Oleg Mikheev
Unregistered




Re: Implementing problems! [Re: Anton_Bashmakov]
      #53043 - 09/06/07 04:38 AM

Anton,

These kind of questions should be asked on a Struts mailing list. There are lots of Struts developers who might help.

Concerning your question.
I've tried to run this JSP in Struts2 application and everything worked with no exceptions:
Code:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<s:head title="" theme="ajax" debug="false"/>
<script type="text/javascript">
dojo.require("dojo.widget.Tree");
</script>
</head>
<body>test</body>
</html>



Does the above code work for you?


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Implementing problems! [Re: Oleg Mikheev]
      #56211 - 10/18/07 09:43 AM

Hi
I am new to struts 2.

I tried the code provided above but I am getting a javascript error saying "dojo is not defined."

can you please help me resolving the issue.

Thanks in advance.
AKP


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 5852

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5