Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Yes show-case_Re: How to use struts 2 JSF plugin?

lupus

2007-07-30

Replies:


Hi Matt,

Thanks a looot.

Yes I have tried the show-case ony for 4 hours but failed (my project time
is tight and too rush), and then I changed my mind to try to create the
"shortcut" jsf page to test, failed too. Now, I think you are right, I have
to calm down to look into the show-case and let u know my progress :-).

A+

Lupus


mraible wrote:
>
> Have you looked at the showcase example (it's part of the Struts
> downloads)? That's how I figured it out.
>
> Matt
>
>
> lupus wrote:
>>
>> Thanks Matt,
>>
>> Sorry that I mailed you directly the response, I am not familaw with
>> nabble :).
>>
>> I think the problem is in the configuration of struts-jsf.xml and the
>> action mapping in the corresponding jsf page. But I do not know how to
>> fix it, because from the beginning I am not clear how it works, and what
>> configurations I have to do to get it working.
>>
>> If possible, do u mind showing me a simple example?
>>
>> Thank you very much!
>>
>> Lupus
>>
>>
>>
>> mraible wrote:
>>>
>>> Have you added the JSF implementation's JARs to your classpath?
>>>
>>> Matt
>>>
>>>
>>> lupus wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I cannot get Struts 2 JSF plugin working, the plugin documentation
>>>> (http://struts.apache.org/2.x/docs/jsf-plugin.html) is not clear for me
>>>> to follow and the jsf show-case mixed all the things together..., I do
>>>> not know what configurations I need to get the JSF plugin working. I
>>>> tried and failed. what I want to achieve is "when you input your name
>>>> in jsf page, there comes a greeting page".
>>>>
>>>> In the follow is what I have tried:
>>>>
>>>> 1. I add JavaServer Faces Servlet Configuration in web.xml as what the
>>>> show-case does, but I get the error message: The requested resource
>>>> (Servlet faces is not available) is not available.
>>>>
>>>>     <!-- JavaServer Faces Servlet Configuration, not used directly
>>>> -->
>>>>    <servlet>
>>>>    <servlet-name>faces</servlet-name>
>>>>     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
>>>>    <load-on-startup>1</load-on-startup>
>>>>    </servlet>
>>>>
>>>>    <!-- JavaServer Faces Servlet Mapping, not called directly -->
>>>>    <servlet-mapping>
>>>>      <servlet-name>faces</servlet-name>
>>>>        <url-pattern>*.action</url-pattern>
>>>>      </servlet-mapping>
>>>>
>>>> 2. I add struts-jsf.xml into struts.xml
>>>>
>>>> <!DOCTYPE struts PUBLIC
>>>>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>>
>>>> <struts>
>>>>  <package name="jsf" extends="jsf-default" namespace="/jsf">
>>>>
>>>>     <result-types>
>>>>       <result-type name="jsf"
>>>> class="org.apache.struts2.jsf.FacesResult" />
>>>>     </result-types>
>>>>
>>>>   <interceptors>
>>>>     <interceptor-stack name="jsfFullStack">
>>>>      <interceptor-ref name="params" />
>>>>      <interceptor-ref name="basicStack"/>
>>>>      <interceptor-ref name="jsfStack"/>
>>>>     </interceptor-stack>
>>>>   </interceptors>
>>>>
>>>>   <default-interceptor-ref name="jsfFullStack"/>
>>>>
>>>>  </package>
>>>>  
>>>>  <package name="web.jsf.personBean" extends="jsf"
>>>> namespace="/web/jsf/PersonBean">
>>>>  
>>>>   <action name="getPersonName" class="web.jsf.PersonBean"
>>>> method="getPersonName">
>>>>     <result name="success" type="jsf" />
>>>>   </action>
>>>>    <action name="setPersonName" class="web.jsf.PersonBean"
>>>> method="setPersonName">
>>>>     <result name="success" type="jsf" />
>>>>   </action>
>>>>  </package>
>>>>
>>>> </struts>
>>>>
>>>> 3. My java class PersonBean.java:
>>>> package web.jsf;
>>>>
>>>> public class PersonBean {
>>>>
>>>>   String personName;
>>>>  
>>>>   /**
>>>>   * @return Person Name
>>>>   */
>>>>   public String getPersonName() {
>>>>     return personName;
>>>>   }
>>>>
>>>>   /**
>>>>   * @param Person Name
>>>>   */
>>>>   public void setPersonName(String name) {
>>>>     personName = name;
>>>>   }
>>>> }
>>>>
>>>> 4. Here is my jsp inputname.jsp
>>>>
>>>> <f:view>
>>>>    <h1>
>>>>     <h:outputText value="input name header"/>
>>>>    </h1>
>>>>    <h:form id="helloForm">
>>>>     <h:outputText value="Prompt"/>
>>>>     <h:inputText value="#{action.personBean.personName}" />
>>>>     <h:commandButton action="#{action.personBean}" value="Greeting
>>>> word" />
>>>>     </h:form>
>>>>   </f:view>
>>>>
>>>> I think in my jsp action mapping may not be correct, but I don't know
>>>> how to fix it.
>>>>
>>>> Did I miss some configurations ? Please help me out.
>>>>
>>>> Thank you very much!!!:-)
>>>>
>>>
>>>
>>
>>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.