You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Christian Wiesing <cw...@ordix.de> on 2006/11/07 13:57:04 UTC

Problem with strust-faces

Hello,

i have a problem with struts-faces with tiles and myfaces. I use the 
following libraries:

- Struts 1.2.9
- Struts-Faces 1.3.5
- MyFaces 1.1.5-Snapshot (6. Nov)
 
I updated the the tiles-templates (<f:view> and <f:subview>), the 
RequestProcessor, and so on and it seems to be working. But everytime 
when i press the submit-Button i get a 404-error, because it tries to 
open the following URL:
http://localhost:8080/project-centre/layouts/root-layout.do

But he should execute the "adminenumeration"-Action and not the 
root-layout. I don't find an error. What can i do to get it working? Thanks!

Regards,

Christian

See the source-code below:

-----------------------------------------------------
JSP:(adminenumeration)
<%@ imports.... %>

<h:messages/>

<s:form action="/adminenumeration">
        <h:commandButton value="submit"/>

        <h:inputText value="#{value1}" />
        <h:inputText value="#{value2}" />
        <h:inputText value="#{value3}" />
</s:form>

-----------------------------------------------------

STRUTS-CONFIG.XML:
...
<action
      path="/adminenumeration"
      
type="net.tmobile.depromos.present.struts.actions.admin.EnumerationAdminAction"
      name="enumerationAdminForm"
      scope="request"
      input="Failure"
      parameter="method"
      unknown="false"
      validate="true"
    >
      <forward
        name="form"
        path="main.admin.enumeration"
        redirect="false"
      />
      <forward
        name="Success"
        path="main.admin.enumeration"
        redirect="false"
      />
      <forward
        name="Cancel"
        path="main.admin.enumeration"
        redirect="true"
      />
      <forward
        name="Failure"
        path="/adminenumeration.do?method=correctInput"
        redirect="false"
      />
    </action>
...
<controller contentType="text/html;charset=UTF-8" locale="true" 
nocache="true">
        <set-property property="processorClass" 
value="org.apache.struts.faces.application.FacesTilesRequestProcessor"/>
        <set-property property="inputForward" value="true"/>
    </controller>
-----------------------------------------------------

TILES-DEF:
...
<definition name="root-layout" path="/layouts/root-layout.jsf">
        <put name="menu" value="menu-definition"/>
        <put name="main-applicationline-applicationname" 
value="/layouts/main-applicationline-applicationname.jsp"/>
        <put name="main-applicationline-toolbar" 
value="main-applicationline-toolbar-definition"/>
        <put name="main-breadcrumbs" value="main-breadcrumbs-definition"/>
        <put name="main-body-top" value="main-body-top-definition"/>
        <put name="main-body-pane" value="main-body-pane-definition"/>
        <put name="main-body-footer" value="main-body-footer-definition"/>
        <put name="main-footer" value="empty-definition"/>
    </definition>
...

-----------------------------------------------------

WEB.XML:
...
<servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>
        javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Action Servlet Configuration -->
    <servlet>
        <servlet-name>action</servlet-name>
        
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
            <param-name>definitions-config</param-name>
            <param-value>/WEB-INF/tiles-defs.xml</param-value>
        </init-param>
        .....
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>validate</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
...
  <servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>

<servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

...





Re: Problem with strust-faces

Posted by Matthias Wessendorf <ma...@apache.org>.
Christian,

my recommendation is NOT! to use that lib.

It might look "nice" to use JSF-Views with Struts-Actions/ActionForms.
And the end of the day, you don't really want that.
David Geary said: "why are you trying to ride two elephants at the same time" ?

You want is to add the FacesServlet and port parts of the app to Faces.
That way you also can *learn* JSF and there is not need to overhaul
the app in once.
It is like you add Spring. Step-by-Step. A soft migration.

Use Tiles/Struts and JSF/Facelets (not to hard to create a *separate*
Facelets layout)

Greetz,
Matthias

On 11/7/06, Christian Wiesing <cw...@ordix.de> wrote:
> Hello,
>
> i have a problem with struts-faces with tiles and myfaces. I use the
> following libraries:
>
> - Struts 1.2.9
> - Struts-Faces 1.3.5
> - MyFaces 1.1.5-Snapshot (6. Nov)
>
> I updated the the tiles-templates (<f:view> and <f:subview>), the
> RequestProcessor, and so on and it seems to be working. But everytime
> when i press the submit-Button i get a 404-error, because it tries to
> open the following URL:
> http://localhost:8080/project-centre/layouts/root-layout.do
>
> But he should execute the "adminenumeration"-Action and not the
> root-layout. I don't find an error. What can i do to get it working? Thanks!
>
> Regards,
>
> Christian
>
> See the source-code below:
>
> -----------------------------------------------------
> JSP:(adminenumeration)
> <%@ imports.... %>
>
> <h:messages/>
>
> <s:form action="/adminenumeration">
>         <h:commandButton value="submit"/>
>
>         <h:inputText value="#{value1}" />
>         <h:inputText value="#{value2}" />
>         <h:inputText value="#{value3}" />
> </s:form>
>
> -----------------------------------------------------
>
> STRUTS-CONFIG.XML:
> ...
> <action
>       path="/adminenumeration"
>
> type="net.tmobile.depromos.present.struts.actions.admin.EnumerationAdminAction"
>       name="enumerationAdminForm"
>       scope="request"
>       input="Failure"
>       parameter="method"
>       unknown="false"
>       validate="true"
>     >
>       <forward
>         name="form"
>         path="main.admin.enumeration"
>         redirect="false"
>       />
>       <forward
>         name="Success"
>         path="main.admin.enumeration"
>         redirect="false"
>       />
>       <forward
>         name="Cancel"
>         path="main.admin.enumeration"
>         redirect="true"
>       />
>       <forward
>         name="Failure"
>         path="/adminenumeration.do?method=correctInput"
>         redirect="false"
>       />
>     </action>
> ...
> <controller contentType="text/html;charset=UTF-8" locale="true"
> nocache="true">
>         <set-property property="processorClass"
> value="org.apache.struts.faces.application.FacesTilesRequestProcessor"/>
>         <set-property property="inputForward" value="true"/>
>     </controller>
> -----------------------------------------------------
>
> TILES-DEF:
> ...
> <definition name="root-layout" path="/layouts/root-layout.jsf">
>         <put name="menu" value="menu-definition"/>
>         <put name="main-applicationline-applicationname"
> value="/layouts/main-applicationline-applicationname.jsp"/>
>         <put name="main-applicationline-toolbar"
> value="main-applicationline-toolbar-definition"/>
>         <put name="main-breadcrumbs" value="main-breadcrumbs-definition"/>
>         <put name="main-body-top" value="main-body-top-definition"/>
>         <put name="main-body-pane" value="main-body-pane-definition"/>
>         <put name="main-body-footer" value="main-body-footer-definition"/>
>         <put name="main-footer" value="empty-definition"/>
>     </definition>
> ...
>
> -----------------------------------------------------
>
> WEB.XML:
> ...
> <servlet>
>         <servlet-name>faces</servlet-name>
>         <servlet-class>
>         javax.faces.webapp.FacesServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>
>     <!-- Action Servlet Configuration -->
>     <servlet>
>         <servlet-name>action</servlet-name>
>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>               <init-param>
>             <param-name>definitions-config</param-name>
>             <param-value>/WEB-INF/tiles-defs.xml</param-value>
>         </init-param>
>         .....
>         <init-param>
>             <param-name>config</param-name>
>             <param-value>/WEB-INF/struts-config.xml</param-value>
>         </init-param>
>         <init-param>
>             <param-name>validate</param-name>
>             <param-value>true</param-value>
>         </init-param>
>         <init-param>
>             <param-name>debug</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <init-param>
>             <param-name>detail</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <load-on-startup>2</load-on-startup>
>     </servlet>
> ...
>   <servlet-mapping>
>     <servlet-name>faces</servlet-name>
>     <url-pattern>*.jsf</url-pattern>
>   </servlet-mapping>
>
> <servlet-mapping>
>         <servlet-name>action</servlet-name>
>         <url-pattern>*.do</url-pattern>
>     </servlet-mapping>
>
> ...
>
>
>
>
>
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com