I am not sure it helps you with Dojo, but may want to look at either a) the
JSON result plugin which will return the actionErrors as part of the object
graph.  You could also create your own objects and have the plugin encode
those in JSON and process them on the client side.   b) I vaguely remember
seeing an early demo of the REST plugin where actionErrors were returned as
part of the JSON output when calling an action.  You can look at the source
code for that plugin or try it, but that may change your design
significantly.



sajidbigler wrote:
> 
> Hi please see Answers in bold
> Greg:
> Sorry, I can't understand what you are talking about in scenario 1, on a
> redirect result there is no output response except the http redirect
> command.
> Sajid:Its normal Ajax call no redirect.
> 
> signup.jsp
> 
> <html>
> <head>
> <title>Service Owner</title>
> <link href="<s:url value='/css/main.css'/>" rel="stylesheet"
>       type="text/css" />
> <sx:head cache="true" debug="true" parseContent="true"/>
> </head>
> <script language="JavaScript" type="text/javascript">
> function avalibility(username) {
>            dojo.io.bind({
>             url: "<s:url
> value='/userAvailableCheckAction.action'/>?username="+username,
>             load: function(type, data, evt) {
>                       var username1 = dojo.byId("username");
>                       
>                       username1.value=data
>                                 },
>             mimeType: "text/html"
>         });
>     }
> 
> </script>
> <s:form action="doSignUP" method="POST"       theme="simple">
> <s:actionerror /><s:actionmessage/>
> <s:textfield label="User Name" name="username" required="true"
> requiredposition="left" id="username"
> onblur="javascript:avalibility(this.value);return false;"  />
> <s:submit value="Save" align="center"/>
> </s:form>
> 
> struts.xml
> 
> <interceptors>
>                       <interceptor name="redirectMessage"
>                       
> class="com.teleparadigm.mms.application.common.RedirectMessageInterceptor"
> />
>                       <interceptor-stack name="myStack">
>                               <interceptor-ref name="redirectMessage" />
>                               <interceptor-ref 
> name="paramsPrepareParamsStack" />
>                               <interceptor-ref name="defaultStack" />
>                       </interceptor-stack>
>               </interceptors>
>               <default-interceptor-ref name="myStack" />
> 
>               <action name="userAvailableCheckAction"
>               
> class="com.teleparadigm.mms.application.useravailability.UserAvailabilityAction">
>                       <result>/pages/available.jsp</result>
>               </action>
> 
> available.jsp
> 
> <%...@taglib prefix="s" uri="/struts-tags"%>
> <% System.out.println("In JSP username
> "+request.getParameter("username"));
> System.out.println("In JSP exist "+request.getParameter("exist"));
> 
> if(request.getParameter("exist")==null){
> %>
> <s:property value="%{username}" />
> <%}else{%>
> alert('User Already Exist !...');
> <%}%>
> 
> UserAvailabilityAction.java
> 
> package com.teleparadigm.mms.application.useravailability;
> 
> import java.util.Map;
> 
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpSession;
> 
> import org.apache.struts2.interceptor.ServletRequestAware;
> 
> import com.opensymphony.xwork2.ActionContext;
> import com.opensymphony.xwork2.ActionSupport;
> import com.teleparadigm.mms.application.common.Owner;
> import com.teleparadigm.mms.application.login.LoginDAO;
> 
> public class UserAvailabilityAction  extends ActionSupport  implements
> ServletRequestAware
> {
>       
> 
>       private HttpServletRequest request;
> 
>       public void setServletRequest(HttpServletRequest request){
>               this.request = request;
>       }
> 
>       public HttpServletRequest getServletRequest(){
>               return request;
>       }
> 
>       UserAvailabilityDAO uadao=new UserAvailabilityDAO();
>       private String username = null;
>       
>       public String execute() throws Exception {
>               System.out.println("UserAvailabilityAction--->"+this. 
> getUsername());
>               boolean result=uadao.checkUserNameAvailability(this.
> getUsername().trim());
>               System.out.println("result--->"+result);
> 
> 
>               if(!result){
>                       return SUCCESS;
>               }else{
>                       username="";
>                       addActionError("User Already Exists..plz use another 
> username..");
>                       return SUCCESS;
>               }
>           }
> 
>       public String getUsername() {
>               return username;
>       }
>       public void setUsername(String username) {
>               this.username = username;
>       }
> 
> 
> 
> 
> 
> 
> }
> 
> For scenario 2, you still haven't provided enough info to help you.
> Greg:
> - What's your interceptor stack look like? Does it include the 'workflow'
> interceptor?
> 
> Sajid:
> <interceptors>
>                       <interceptor name="redirectMessage"
>                       
> class="com.teleparadigm.mms.application.common.RedirectMessageInterceptor"
> />
>                       <interceptor-stack name="myStack">
>                               <interceptor-ref name="redirectMessage" />
>                               <interceptor-ref 
> name="paramsPrepareParamsStack" />
>                               <interceptor-ref name="defaultStack" />
>                       </interceptor-stack>
>               </interceptors>
>               <default-interceptor-ref name="myStack" />
> 
> <action name="MMSUpload"
>                       
> class="com.teleparadigm.mms.application.mms.MMSUploadAction">
>                       <interceptor-ref name="i18n" />
>                       <interceptor-ref name="fileUpload" />
>                       <interceptor-ref name="basicStack" />
>                       <result name="input">/pages/ComposeMMS.jsp</result>
>                       <result name="error" type="redirectAction">
>                               showDynamicTreeActionMMS
>                       </result>
>                       <result>/pages/upload_success.jsp</result>
>               </action>
>               <action name="showDynamicTreeActionMMS"
>               
> class="com.teleparadigm.mms.application.dynamictree.ShowDynamicTreeAction">
>                       <result name="input">/pages/ComposeMMS.jsp</result>
>                       <result name="error" type="redirect">/index.jsp</result>
>                       <result>/pages/ComposeMMS.jsp</result>
>               </action>
> 
> 
> Greg:
> - How is your action configured? does it include a result with
> name="input"?
> Sajid:
> yes it includes as shown above
> Greg:
> - What's your result jsp look like? does it include anything to display
> errors or messages?
> Sajid:
> 
> ComposeMMS.jsp
> 
> <%@ page contentType="text/html; charset=UTF-8" %>
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> <%
> 
> request.getSession().setAttribute( "tab" ,"MMS");
>  %>
> <html>
> <head>
> <title>Service Owner</title>
> <link href="<s:url value='/css/main.css'/>" rel="stylesheet"
>       type="text/css" />
> <sx:head cache="true" debug="true"/>
> </head>
> 
> <script language="JavaScript" type="text/javascript">
> 
>     dojo.event.topic.subscribe("treeSelected", function
> treeNodeSelected(node) {
>            dojo.io.bind({
>             url: "<s:url
> value='/dynamicTreeSelectAction.action'/>?nodeId="+node.node.widgetId,
>             load: function(type, data, evt) {
>                 var divDisplay = dojo.byId("displayId");
>                 divDisplay.innerHTML=data;
>                  },
>             mimeType: "text/html"
>         });
>     });
> </script>
> <sx:tree 
>     id="tree"
>     rootNode="%{#session.treeRootNode}" 
>     childCollectionProperty="children" 
>     nodeIdProperty="id"
>     nodeTitleProperty="name"
>     treeSelectedTopic="treeSelected">
> </sx:tree> 
> </div>
> 
> 
> <div id="content">
> <h3>Please Select Tree Node to  place the Content</h3>
> <s:actionerror /> <s:fielderror /> 
> <s:form action="MMSUpload"
>       method="POST" enctype="multipart/form-data" id="form" >
>       <s:div id="displayId"></s:div>
> 
>       <s:textfield name="MMSFrom" label="MMS From " />
>       <s:textfield name="MMSSubject" label="MMS Subject" />
>       <s:textfield name="MMSText" label="MMS Text" />
>       <s:textfield name="MMSName" label="MMS Name" />
>       <s:file name="upload" label="File 1" />
>       <s:file name="upload" label="File 2" />
>       
>       <s:submit align="center" />
> 
> </s:form>
> Gerg
> Also what steps have you done to try and resolve the problem? Have you
> stepped through these scenarios in a debugger? 
> sajid
> i have taken RedirectMessageInterceptor.java  from the link as given above
> and was unable to step as i really never ever able to set sourcecode of
> sturts2.1.6 in eclipse and i use only binary no sourceplz suggest me to do
> this.i know how to set debugging mode but when ever i try to set in my
> eclise it will struck wont response... :( 
> Gerg
> You should include at a minimum your struts configuration (struts.xml) and
> jsp file.
> 
> 
> 
> 



-- 
View this message in context: 
http://www.nabble.com/Actionerror%27s-wont-be-shown-when-ajax-call-or-when-we-do-type%3D%22redirectAction%22-using-struts2.1.6-tp22490692p22519883.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to