Exception when using ServletActionRedirectResult with @Resul

 
Post new topic   Reply to topic    WanTii, Inc. Tech Forum Forum Index // Struts 2.x Advanced
View previous topic :: View next topic  
Author Message
amin



Joined: 24 Mar 2008
Posts: 6

PostPosted: Tue Nov 25, 2008 6:09 pm    Post subject: Exception when using ServletActionRedirectResult with @Resul Reply with quote
Hi

I am trying to redirect the success of an action to another action using the following:

@Results({
@Result(name="success", value="viewContact", params= {"namespace", "/","actionName,"viewContact", "contactId", "${contactId}", "contactType", "${contactType}"}, type=ServletActionRedirectResult.class),
@Result(name="error", value="search.error", type=TilesResult.class)
})


However I am getting the following exception:

Caused by: ognl.NoSuchPropertyException: org.apache.struts2.dispatcher.ServletActionRedirectResult.contactId
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:132)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656)
at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:197)
at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:393)


I have looked around and upgraded to Struts 2.1.2 and am still getting the exception. Would it be possible if someone can advise me on what I am doing wrong.


Thanks
Amin
Back to top
View user's profile Send private message
amin



Joined: 24 Mar 2008
Posts: 6

PostPosted: Wed Nov 26, 2008 3:37 pm    Post subject: Reply with quote
Hi

Can anyone help with the problem that I am encountering?


Cheers
Back to top
View user's profile Send private message
wesw
Site Admin


Joined: 13 Jul 2007
Posts: 85
Location: USA

PostPosted: Wed Nov 26, 2008 4:21 pm    Post subject: Reply with quote
Try doing the following -
Code:

@Result(
  name="success",
  value="viewContact",
  params= {
    "namespace", "/",
    "actionName, "viewContact",
    "requestParameters", "${#{
      'contactId':contactId,
      'contactType',contactType
    }}"}
  type=ServletActionRedirectResult.class)

I'm not sure if that exact syntax will work, but the error message you are getting indicates that it is trying to call setters on ServletActionRedirectResult that do not exist. However, there is a property called requestParameters that is a Map<String,String>. You might be able to massage the syntax above just enough to get it to work.
_________________
Wesley Wannemacher
President, Head Engineer/Consultant
WanTii, Inc.
http://www.wantii.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amin



Joined: 24 Mar 2008
Posts: 6

PostPosted: Wed Nov 26, 2008 5:28 pm    Post subject: Reply with quote
Hi

Thanks for your reply, unfortunately that did not work, i now get the following error

Code:

Cannot create type interface java.util.Map from value ${#{'contactId':contactId,'contactType':contactType }} - [unknown location]
   at com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:152)
   at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:313)



followed by:

Code:

Caused by: java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of class org.apache.struts2.dispatcher.ServletActionRedirectResult with modifiers "private"
   at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)




Thanks for your help!
Back to top
View user's profile Send private message
Post new topic   Reply to topic    WanTii, Inc. Tech Forum Forum Index // Struts 2.x Advanced All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

alexisBlue v1.2 // Theme Created By: Andrew Charron and Web Hosting Bluebook
Powered by phpBB © 2001, 2002 phpBB Group