문제

I am trying to add two numbers together and display the output, but I'm having rendering problems.

I get this from the ajax log. (Spaced out for readability)

info [12:44:10.893]: Element error 
<error>
  <error-name>
    class com.sun.faces.context.FacesFileNotFoundException
  </error-name>
  <error-message>
    <![CDATA[/WEB-INF/WEB-INF/intro.xhtml Not Found in ExternalContext as a Resource]]>
  </error-message>
</error>

I do not see where it is getting the two WEB-INF folders in the path name.

The second part of the this question is that I am not sure where calculator.sum should be called at either. This may be effecting the result or need to be in a separate question. #{calculator.sum} is the output that is called when the button is clicked.

This is the form that I am editing.

 <rich:panel id="UserManagePanel" header="Welcome to test">

 <a href="main">Enter The WebFlow</a>
  <br/>
  <br/>
  <br/>
    <h:inputText id="additive1" value="#{calculator.a}"/>
  <br/>
    <h:inputText id="additive2" value="#{calculator.b}"/>
  <br/>
    <a4j:commandButton type="button" id="btn_add" action="#{calculator.sum}" value="Add" reRender="out" execute="@form"/>
  <br/>

  <a4j:outputPanel id="out">
    <h:outputText value="#{calculator.sum}" rendered="true"/>
  </a4j:outputPanel>
  <br/>

  <a4j:log/>

   </rich:panel>
  </h:form>

Supporting Docs:

main-flow.xml

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/webflow
        http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd">

    <view-state id="Page2">
        <transition on="gotoPage3" to="Page3"/>
        <!--  <transition on="printDets">
            <evaluate expression="userBean.printDetails()" />
        </transition> -->
    </view-state>

    <view-state id="Page3">
        <transition on="gotoSubFlow" to="Page3subflow"/>
        <transition on="gotoPage5" to="Page5"/>
    </view-state>

    <view-state id="Page5">
    </view-state>

    <subflow-state id="Page3subflow" subflow="subflow1">
    </subflow-state>

    <end-state id="finish" />

</flow>

web.xml

<?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

<!-- The master configuration file for this Spring web application -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/config/web-application-config.xml
    </param-value>
</context-param>

<!-- Declare Spring Security Facelets tag library 
<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param> -->

<!-- Enforce UTF-8 Character Encoding -->
<filter>
    <filter-name>charEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>charEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Enables Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

<!--  
<context-param>
    <param-name>org.richfaces.skin</param-name>
    <param-value>joshCustom</param-value>
</context-param>
-->
<context-param>
    <param-name>org.richfaces.enableControlSkinning</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>facelets.SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<!-- Enables special Facelets debug output during development -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- Causes Facelets to refresh templates during development -->
<context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
</context-param>

<!--
    Uncomment this to disable partial state saving when using Apache MyFaces 2 !!
<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>
-->

<!-- Loads the Spring web application context -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>

<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
<servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
</servlet-mapping>

<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Just here so the JSF implementation can initialize -->
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>

<!-- Added for JAX-WS compatibility -->
<servlet>
    <servlet-name>JAX-WS Servlet</servlet-name>
    <servlet-class>demo.SimpleServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>JAX-WS Servlet</servlet-name>
    <url-pattern>/SimpleService</url-pattern>
</servlet-mapping>



  <!-- The welcome file -->
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app><?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

    <!-- The master configuration file for this Spring web application -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/config/web-application-config.xml
        </param-value>
    </context-param>

    <!-- Declare Spring Security Facelets tag library 
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
    </context-param> -->

    <!-- Enforce UTF-8 Character Encoding -->
    <filter>
        <filter-name>charEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Enables Spring Security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!--  
    <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>joshCustom</param-value>
    </context-param>
    -->
    <context-param>
        <param-name>org.richfaces.enableControlSkinning</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <!-- Enables special Facelets debug output during development -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <!-- Causes Facelets to refresh templates during development -->
    <context-param>
        <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
        <param-value>1</param-value>
    </context-param>

    <!--
        Uncomment this to disable partial state saving when using Apache MyFaces 2 !!
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>false</param-value>
    </context-param>
    -->

    <!-- Loads the Spring web application context -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

    <!-- Map all /spring requests to the Dispatcher Servlet for handling -->
    <servlet-mapping>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>

    <!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Just here so the JSF implementation can initialize -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>

    <!-- Added for JAX-WS compatibility -->
    <servlet>
        <servlet-name>JAX-WS Servlet</servlet-name>
        <servlet-class>demo.SimpleServiceImpl</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>JAX-WS Servlet</servlet-name>
        <url-pattern>/SimpleService</url-pattern>
    </servlet-mapping>

  <!-- The welcome file -->
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>

Java class Calculator.java

package demo;

import javax.faces.bean.*;

import org.springframework.stereotype.Component;

@ManagedBean
@Component
@ViewScoped
public class Calculator implements java.io.Serializable{

      private static final long serialVersionUID = -3832235132261771583L;

      private int _a;
      private int _b;

      public int getA() { return _a; }
      public void setA(int a) { _a = a; }

      public int getB() { return _b; }
      public void setB(int b) { _b = b; }

      public int getSum()
      {
        return _a + _b;
      }

}

Libraries I'm Using: Using Richfaces 4.3.4 Spring Security 3.1.3 JSTL 1.2.1 Spring 3.2.0.RELEASE

도움이 되었습니까?

해결책 2

To get this to work a few things had to happen.

1) WEB-INF/ from the webmvc-config.xml under the flowlistener.
2) and had to be used to at least debug it.
3) The form must be in and tags.
4) The url must use webflow

http://localhost:8080/CLPWeb/spring/grantSearchFlow?test

  rather than

http://localhost:8080/CLPWeb/spring/WEB-INF/templates/views/test.xhtml

Used url's as code to get it to validate.

다른 팁

Since the calculator.sum only returns the number (and doesn't do anything in the background) there is no point calling it when you click the button.

I don't know what causes the error but WEB-INF is for config files and stuff like that. If you have any (x)html pages in there move them out.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top