Announcement Announcement Module
Collapse
No announcement yet.
Spring + DWR + redirect problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + DWR + redirect problem

    Hi

    I'm using dwr to submit a form, everything's fine except that I dont get the success view or the cancel view back to my div.

    I'm getting the following warning
    Code:
    Apr 17, 2008 18:37:51 PM INFO  org.directwebremoting.impl.DefaultRemoter  - Exec: dwrUtils.forwardToString()
    Apr 17, 2008 18:37:51 PM WARN  org.directwebremoting.util.SwallowingHttpServletResponse  - Ignoring call to sendRedirect(index)
    My controller bean config is as following
    Code:
    <bean name="addContactController" class="com.edifice.controller.AddContactController">
            <property name="sessionForm" value="false"/>
            <property name="commandName" value="contactCommand"/>
            <property name="commandClass" value="com.edifice.dao.Contact"/>
            <property name="formView" value="contactForm"/>
            <property name="successView" value="redirect:index"/>
            <property name="cancelView" value="redirect:index" />
            <property name="cancelParamKey" value="cancel"/>
            <property name="validator" ref="contactValidator"/>
            
            <property name="salutations" ref="salutations"/>
            <property name="contactDaoImpl" ref="contactDaoImpl"/>
            <property name="clientDaoImpl" ref="clientDaoImpl"/>
        </bean>
    Following is my dwr configuration
    Code:
    <dwr:configuration />
        <dwr:controller id="dwrController" debug="false" />
        
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="alwaysUseFullPath" value="true"/>
            <property name="mappings">
                <props>
                    <prop key="/admin/index">indexController</prop>
                    <prop key="/admin/addclient">addClientController</prop>
                    <prop key="/admin/adddomain">addDomainController</prop>
                    <prop key="/admin/addplan">addPlanController</prop>
                    <prop key="/admin/addcontact">addContactController</prop>
                    <prop key="/admin/showcontacts">showContactsController</prop>
                    <prop key="/admin/showclients">showClientsController</prop>
                    <prop key="/admin/managecontacts">manageContactsController</prop>
                </props>
            </property>
        </bean>
        
        <bean id="dwrUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/engine.js">dwrController</prop>
                    <prop key="/util.js">dwrController</prop>
                    <prop key="/interface/**">dwrController</prop>
                    <prop key="/call/**">dwrController</prop>
                    <prop key="/**">dwrController</prop>
                </props>
            </property>
        </bean>
    
        <bean id="dwrUtils" class="com.edifice.dwr.DwrUtils" scope="session">
            <dwr:remote javascript="dwrUtils">
                <dwr:convert type="bean" class="com.edifice.dwr.DwrUtils">
                    <dwr:include method="forwardToString"/>
                </dwr:convert>
            </dwr:remote>
        </bean>
    Im parsing the url (with parameters+values) to dwrUtils.forwardToString method
    by javascript
    Code:
    function submitAddContactForm(){
        var url = "/admin/addcontact";
        url += getParameterNamesAndValues();
        dwrUtils.forwardToString(url,function(dataFromServer) {
            dwr.util.setValue("formDiv", dataFromServer , { escapeHtml:false });
        });
        
        return false;
    }
    
    function getParameterNamesAndValues(){
        var namesAndValues = "?";
        var form = document.getElementById("contactForm");
        for (var i = 0; i < form.length; i++){
            namesAndValues += form[i].name;
            namesAndValues += "=";
            namesAndValues += form[i].value;
            namesAndValues += "&";
        }
        
        return namesAndValues;
    }
    DwrUtils.java
    Code:
    public class DwrUtils {
    
        private Log logger = LogFactory.getLog(getClass());
        private WebContext wctx;
        private String result;
    
        public String forwardToString(String url) {
            result = "";
            wctx = WebContextFactory.get();
            try {
                result = wctx.forwardToString(url);
            } catch (Exception e) {
                logger.info("Exception : " + e);
            }
            return result;
        }
    }
    I was trying to find a solution for this the whole day, couldn't find any thing.

    the org.directwebremoting.util.SwallowingHttpServletRe sponse - Ignoring call to sendRedirect(index) only happens when im redirecting the request to another controller.

    what might i be doing wrong here? Please some one help me fix this.

    Thanks in advance...

  • #2
    You probably meant to post this message in the web forum?

    Comment


    • #3
      Hi
      I'm not familier with posting in forums, have i posted in a wrong thread???

      Comment


      • #4
        I just moved this thread to the Web forum. The original forum is specifically for the "Spring Integration" project. You should have a better chance of getting answers to your problem here.

        Comment


        • #5
          Thank you... Mark Fisher

          Comment


          • #6
            hi

            could any one help me.. please...

            did any one had this issue? how did u solve it?

            Comment

            Working...
            X