struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4775) Action class Attributes(value stack) is not getting populated through Ajax url request parms
Date Mon, 27 Mar 2017 19:02:41 GMT

    [ https://issues.apache.org/jira/browse/WW-4775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15943839#comment-15943839
] 

Lukasz Lenart edited comment on WW-4775 at 3/27/17 7:01 PM:
------------------------------------------------------------

Thanks Lukasz for quick reply. I updated the the snippets below, please let me know if further
information is need on this.


Struts
{code:xml}
<action name="strustSampleActionNameGet" class="struts.action.strutsSampleActionClass">
      	<result name="success">/views/successPage.jsp</result> 
      	 <result name="error">/views/ErrorPage.jsp</result>     
       </action>  
{code}

Call from jsp
{code:javascript}
onclick="callAjaxGet();"
{code}

Js using jquery

{code:javascript}
function callAjaxGet(){ 
 $.ajax( { 
 url : "strustSampleActionNameGet", 
 type: "GET", 
 data : 
 { param : "2"} 
 , 
 success : function(response) 
 {alert('success');} 
 , 
 error : function(e) 
 {alert('Message on error');} 
 }); 
{code}

Action 

{code:java}
public class strutsSampleActionClass extends ActionSupport implements SessionAware, ServletRequestAware,
ServletResponseAware{ 
 private String param1; 

 //getter and setter exist 
 public string getParam1(){ 
return param1; 
 } 

 public void setParam1(String param1){ 
this.param1 = param1;
 } 

 public String execute() throws Exception{
try { 
// getParam1(); is returning null 
String param1ValueStack = getParam1(); 

//but we can get it through request Object
String parma1req= getRequest().getParameter("param1");
}
catch(Exception e) {
                       return "error";
        }
      return "success";
{code}




was (Author: nitinperi):
Thanks Lukasz for quick reply. I updated the the snippets below, please let me know if further
information is need on this.


Struts
<action name="strustSampleActionNameGet" class="struts.action.strutsSampleActionClass">
      	<result name="success">/views/successPage.jsp</result> 
      	 <result name="error">/views/ErrorPage.jsp</result>     
       </action>  

Call from jsp
onclick="callAjaxGet();"


Js using jquery
function callAjaxGet(){ 
 $.ajax( { 
 url : "strustSampleActionNameGet", 
 type: "GET", 
 data : 
 { param : "2"} 
 , 
 success : function(response) 
 {alert('success');} 
 , 
 error : function(e) 
 {alert('Message on error');} 
 }); 

Action 

public class strutsSampleActionClass extends ActionSupport implements SessionAware, ServletRequestAware,
ServletResponseAware{ 
 private String param1; 

 //getter and setter exist 
 public string getParam1(){ 
return param1; 
 } 

 public void setParam1(String param1){ 
this.param1 = param1;
 } 

 public String execute() throws Exception{
try { 
// getParam1(); is returning null 
String param1ValueStack = getParam1(); 

//but we can get it through request Object
String parma1req= getRequest().getParameter("param1");
}
catch(Exception e) {
                       return "error";
        }
      return "success";






> Action class Attributes(value stack)  is not getting populated through Ajax url request
parms 
> ----------------------------------------------------------------------------------------------
>
>                 Key: WW-4775
>                 URL: https://issues.apache.org/jira/browse/WW-4775
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Value Stack
>    Affects Versions: 2.5.10
>         Environment: 
>            Reporter: nitin
>             Fix For: 2.5.next
>
>
> Passing request attributes through Ajax - url is not populating the Action Form Attributes
and coming up EMPTY . Instead they are available via request object currently. 
> It was working correctly in struts 2.3.16 BUT it is NOT working with Struts 2.5.10 and
posing big concern to upgrade to newer version which we want due to security risk.
> To better explain the issue, please check the below snippets. It is big part of our applications
code and have a big impacts if we need to move to newer version.
> Below is sniipet of Ajax Method call to Action name:
> {code:javascript}
> function callAjaxGet(value){
> $.ajax( {
> url : "strustSampleActionNameGet",
> type: "GET",
> data : 
> { param : "2"} 
> ,
> success : function(response)
> {alert('success');} 
> ,
> error : function(e)
> {alert('Message on error');} 
> });
> {code}
> ----Action class snippet------
> {code:java}
> public class strustSampleActionClass extends ActionSupport implements SessionAware, ServletRequestAware,
ServletResponseAware{
> private String param1;
> //getter and setter exist
> public string getParam1(){
> ...
> }
> public void setParam1(){
> ...
> }
> public String execute() throws exception
> { //getParam1 is null // but we can get it through request String parma1req= getRequest().getParameter("param1");
}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message