Hi all.

I have one question regarding how to code a page that displaying the search
form and the results together.
I am using the Spring MVC as the presentation layer.

I am able to display the form, but I am not able to display the result from
the referenceData() function at all. can somebone please help me out please?

my controller code

package local.tux.manufacture.web.controller;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.RowSetDynaClass;
import org.apache.commons.lang.StringUtils;
import org.appfuse.webapp.controller.BaseFormController;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.sun.net.httpserver.Authenticator.Success;
import com.sun.org.apache.xerces.internal.impl.dv.xs.DayDV;
import local.tux.manufacture.model.Query;

public class QueryController extends BaseFormController {

        public QueryController(){
                setCommandName("query");
                setCommandClass(Query.class);
        }
        
        protected Object formBackingObject(HttpServletRequest request) throws
Exception{
                return new Query();
        }
        
        
        
        public ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, 
                        Object command, BindException errors) throws Exception{
                return showForm(request, response, errors);
        }
        
        @SuppressWarnings("unchecked")
        protected Map referenceData(HttpServletRequest request, Object command,
Errors errors )throws Exception {
                Map referenceData = new HashMap();
                referenceData.put("result", "hello world");
                return referenceData;
        }

        
}


my jsp code

<%@ include file="/common/taglibs.jsp" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>

<c:set var="buttons">
        <input type="button" style="margin-right: 5px"
                onclick="location.href='<c:url value="result.html"/>'"
                value="<fmt:message key="button.add"/>"
        />
</c:set>


<form:form commandName="query" method="post" 
        action="query.html" id="queryform" onsubmit="return 
validateQuery(this)">
        
        <form:errors path="*" cssClass="error" element="div" />
        <form:hidden path="id" />
        
        <ul>
                <li>
                        <appfuse:label styleClass="desc" key="query.query" />
                        <form:errors path="query" cssClass="fieldError"/>
                        <form:textarea path="query" cssClass="text mediumn"/>
                </li>
                <li class="buttonBar bottom">
                        <input type="submit" class="button" name="save" 
value="<fmt:message
key="button.run" />" />
                        <input type="submit" class="button" name="cancel" 
value="<fmt:message
key="button.cancel"/>" />                       
                </li>
        </ul>
</form:form>
<ul>
        <li>

<c:if test="${result}" >
        has <c:out value="${result}" />
</c:if>
<c:if test="${results}" >
        has <c:out value="${results}" />
</c:if>
        </li>
</ul>

and the bean definition.

<bean id="queryController"
class="local.tux.manufacture.web.controller.QueryController">
                <property name="successView" value="redirect:query.html"/>
        </bean>


Thanks in advance.
-- 
View this message in context: 
http://www.nabble.com/form-and-display-in-a-same-page-tp20095381s2369p20095381.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to