facebook

No form found under ‘subjectForm’ in locale ‘en_AU’

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #250816 Reply

    krunalshah
    Member

    Hi,

    I am trying to populate a form in jsp file via one controller class. I have Subject form which have only two field subjectId and subjectDesc.
    I have one model class called Subject.java which have only two member variable.
    I have one form class called SubjectForm.java which have same two member variable. and getter and setter same as Subject.java.

    I have one jsp file in which I have link to /editSubject?action=Create. after click to this link I should have a subject entry page but Instead I am getting the above error.

    First of all my config file is like

    struts-config.xml

    
    <struts-config>
    
      <!-- ========== Form Bean Definitions =================================== -->
      <form-beans>
    
        <!-- Subject form bean -->
        <form-bean      name="subjectForm"
                        type="com.webapp.forum.controller.form.SubjectForm">
        </form-bean>                
    
      </form-beans>
    
      <!-- ========== Global Forward Definitions ============================== -->
      <global-forwards>
        <forward   name="Subject" path="/Subject.do"/>
      </global-forwards>
    
      <!-- ========== Action Mapping Definitions ============================== -->
      <action-mappings>
    
        <action path     = "/Subject" 
                forward  = "page.subject"/>
    
        <!-- Edit Subject Description -->
        <action    path="/editSubject"
                   type="com.webapp.forum.controller.action.EditSubjectAction"
                     name="subjectForm"
                   scope="request"
                   validate="false">
                <forward name="Home" path="base.definition"/>    
                <forward name="Subject" path="page.subject"/>    
                <forward name="Subjects" path="view.subjects"/>            
        </action>
    
        <!-- Save user registration -->
        <action    path="/saveSubject"
                   type="com.webapp.forum.controller.action.SaveSubjectAction"
                   name="subjectForm"
                   scope="request"
                   input="page.subject">
                <forward name="Home" path="base.definition"/>    
                <forward name="Subjects" path="view.subjects"/>            
        </action>
    
      </action-mappings>
    
    </struts-config>
    
    

    subject.jsp

    
    <%-- start taglib--%>
    <%@ include file="/pages/taglibs.inc.jsp" %>
    <%-- end taglib--%>
    
    <div class="subject">
            
        <html:form action="/saveSubject">
    hello
            <logic:equal name="subjectForm" property="action"
                        scope="request" value="Create">
                  <h2>
                      <bean:message key="app.title" /> 
                        <bean:message key="app.bullet" /> 
                      <bean:message key="title.subject.create"/>
                  </h2>
            </logic:equal>
    hello1    
            <logic:equal name="subjectForm" property="action"
                        scope="request" value="Edit">
                  <h2>
                      <bean:message key="app.title" /> 
                        <bean:message key="app.bullet" /> 
                      <bean:message key="title.subject.edit"/>
                  </h2>
            </logic:equal>
            <html:hidden property="action" write="false"/>
    
            <bean:message key="errors.header" bundle="errors"/>
                <html:errors bundle="errors"/>
            <bean:message key="errors.footer" bundle="errors"/>
            
            <br/>
            <table cellSpacing="0" cellPadding="0" width="100%" border="0" style="border-collapse: collapse" bordercolor="#111111">
              <tr>
                  <td class="tdstyle" style="background-image: url('style/images/top_bg.gif'); width:21px" vAlign="top" align="left" width="254" height="31">
                      <img alt src="style/images/top_left.gif" border="0" width="15" height="31"></td>
                  <td class="tdstyle" style="background-image: url('style/images/top_bg.gif'); width:100%"  align="center" height="31">
                      <logic:equal name="subjectForm" property="action"
                            scope="request" value="Create">
                          <bean:message key="title.registration.create" />
                      </logic:equal>    
                      <logic:equal name="subjectForm" property="action"
                            scope="request" value="Edit">
                          <bean:message key="title.registration.edit" />
                      </logic:equal>    
                  </td>
                  <td class="tdstyle" vAlign="center" align="left" width="15">
                      <img alt src="style/images/top_right.gif" border="0" width="15" height="31"></td>
              </tr>    
            </table>
    
            <table class="tborder" border="0" width="100%">
              <tr class="tdstyle">
                <td align="right">
                  <bean:message key="prompt.subject.id" bundle="labels"/>:
                </td>
                <td align="left">
                  <logic:equal name="subjectForm" property="action"
                              scope="request" value="Create">
                      <bean:message key="prompt.auto.subject.id" bundle="labels"/>:
                      <html:hidden property="subjectId" value="0" write="false"/>
                  </logic:equal>
                  <logic:equal name="subjectForm" property="action"
                              scope="request" value="Edit">
                    <bean:write name="subjectForm" property="subjectId"
                               scope="request" filter="true"/>
                        <html:hidden property="subjectId" write="false"/>
                  </logic:equal>
                </td>
              </tr>
            
              <tr class="tdstyle">
                <td align="right">
                  <bean:message key="prompt.subject.desc" bundle="labels"/>:
                </td>
                <td align="left">
                  <html:text property="subjectDesc" size="45" styleClass="text"/>
                </td>
              </tr>
            
              <tr>
                <td align="center" colspan="2" height="35">
                  <html:submit styleClass="bgbutton">
                    <bean:message key="button.save" bundle="labels"/>
                  </html:submit>
                    
                  <html:reset styleClass="bgbutton">
                    <bean:message key="button.reset" bundle="labels"/>
                  </html:reset>
                    
                  <html:cancel styleClass="bgbutton">
                    <bean:message key="button.cancel" bundle="labels"/>
                  </html:cancel>
                </td>
              </tr>
            </table>
            
            <table cellSpacing="0" cellPadding="0" width="100%" border="0" style="border-collapse: collapse" bordercolor="#111111">
                <tr>
                  <td vAlign="top" align="left" width="12" class="tdstyle">
                  <img alt src="style/images/blc.gif" border="0" width="12" height="13"></td>
                  <td class="tdstyle" style="background-image: url('style/images/bottom.gif'); width:100%" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF"></td>
                  <td vAlign="top" align="right" width="12" class="tdstyle">
                  <img alt src="style/images/brc.gif" border="0" width="12" height="13"></td>
                </tr>
            </table>
            
        </html:form>
    </div>
    
    

    the controller class

    EditSubjectAction.java

    
    
    import java.lang.reflect.InvocationTargetException;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    import org.apache.commons.beanutils.PropertyUtils;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    
    /**Importing UserBean, Constant, SubjectForm class **/
    import com.webapp.Subject;
    import com.webapp.Constants;
    import com.webapp.ForwardConstants;
    import com.webapp.SubjectForm;
    
    
    public final class EditSubjectAction extends Action {
    
    
        private Log log =
            LogFactory.getLog("com.webapp.Action");
    
    
        public ActionForward execute(ActionMapping mapping,
                     ActionForm form,
                     HttpServletRequest request,
                     HttpServletResponse response)
        throws Exception {
    
        // Extract attributes we will need
        HttpSession session = request.getSession();
        String action = request.getParameter("action");
        if (action == null)
            action = "Create";
            if (log.isDebugEnabled()) {
                log.debug("EditSubjectAction:  Processing " + action +
                            " action");
            }
    
        // Is there a currently logged on subject?
        Subject subject = null;
        if (!"Create".equals(action)) {
            
            subject = (Subject) request.getAttribute(Constants.SUBJECT_KEY);
            if (subject == null)
                subject = (Subject) session.getAttribute(Constants.SUBJECT_KEY);
            
            if (subject == null) {
                    if (log.isDebugEnabled()) {
                        log.debug(" Subject is not defined in Session or Request "
                                  + session.getId());
                    }
                    return (mapping.findForward("Test"));
            }
        }
    
        
        // Populate the subject form
        if (form == null) {
                if (log.isTraceEnabled()) {
                    log.trace(" Creating new SubjectForm bean under key "
                              + mapping.getAttribute());
                }
            form = new SubjectForm();
            if ("request".equals(mapping.getScope()))
                request.setAttribute(mapping.getAttribute(), form);
            else
                session.setAttribute(mapping.getAttribute(), form);
        }
        
        SubjectForm    subform = (SubjectForm) form;
        
        if (subject != null) {
                if (log.isTraceEnabled()) {
                    log.trace(" Populating form from " + subject);
                }
                try {
                    PropertyUtils.copyProperties(subform, subject);
                    subform.setAction(action);
                } catch (InvocationTargetException e) {
                    Throwable t = e.getTargetException();
                    if (t == null)
                        t = e;
                    log.error("SubjectForm.populate", t);
                    throw new ServletException("SubjectForm.populate", t);
                } catch (Throwable t) {
                    log.error("SubjectForm.populate", t);
                    throw new ServletException("SubjectForm.populate", t);
                }
        }
    
            // Set a transactional control token to prevent double posting
            if (log.isTraceEnabled()) {
                log.trace(" Setting transactional control token");
            }
            saveToken(request);
    
        // Forward control to the edit Subject page
            if (log.isTraceEnabled()) {
                log.trace(" Forwarding to 'success' page");
            }
    
            return (mapping.findForward(ForwardConstants.SUB_PAGE));
        }
    
    }
    
    

    and this is giving me an error like below

    
    SEVERE: ServletException in '/pages/tiles/subject.jsp': No form found under 'subjectForm' in locale 'en_AU'
    javax.servlet.ServletException: No form found under 'subjectForm' in locale 'en_AU'
        at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
        at org.apache.jsp.pages.tiles.subject_jsp._jspService(org.apache.jsp.pages.tiles.subject_jsp:126)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
        at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:604)
        at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
        at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
        at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
        at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
        at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
        at org.apache.jsp.pages.myLayout_jsp._jspx_meth_tiles_insert_2(org.apache.jsp.pages.myLayout_jsp:360)
        at org.apache.jsp.pages.myLayout_jsp._jspx_meth_html_html_0(org.apache.jsp.pages.myLayout_jsp:148)
        at org.apache.jsp.pages.myLayout_jsp._jspService(org.apache.jsp.pages.myLayout_jsp:91)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
        at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
        at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
        at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
        at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Unknown Source)
    
    
    #250922 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: No form found under ‘subjectForm’ in locale ‘en_AU’

You must be logged in to post in the forum log in