myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlson, John W." <carlso...@llnl.gov>
Subject RE: Include Form into existing JSP
Date Wed, 07 Sep 2011 18:58:10 GMT
Get a grip.  JSF sucks.  Try Struts.  If you get an answer, let me know.

John

-----Original Message-----
From: Hagen, Fabian [mailto:Fabian.Hagen@talanx.com] 
Sent: Wednesday, September 07, 2011 5:56 AM
To: users@myfaces.apache.org
Subject: Include Form into existing JSP

Hello, 

I have a litte problem and cannot believe that this problem is not
solved yet. 
I tried to find a solution via google but without success.

For some of our new websites we want to use JSF 2.0 as our main
web-framework but most of our sites are standard JSP files which include
some other files for navigation etc.

Here is a small snippet:

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
	version="2.0">

	<jsp:directive.include
file="/components/includes/header_core.jsp" /><!-- all the html-head
information -->
	<body>
		<jsp:directive.include
file="/components/includes/mainNav.jsp"/>
	      <jsp:directive.include
file="/components/includes/subNav.jsp"/>
		 <div id="content">
			<c:import url="/forms/easyForm.jsp"/> <!--
includes some simple html form fields -->
		</div>
	</body>
</jsp:root>

Our main purpose is to use the JSF 2.0 for our webforms, so I try like
something like this:
<body>
		<jsp:directive.include
file="/components/includes/mainNav.jsp"/>
	      <jsp:directive.include
file="/components/includes/subNav.jsp"/>
		 <div id="content">
			<c:import url="/forms/jsfForm.xhtml"/> <!--
includes some jsf form fields -->
		</div>
</body>

Here is the form:
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<body>
	<f:view>
		<p>Bitte geben Sie die Daten ein:</p>
		<h:messages showDetail="true" showSummary="false" />
		<h:form id="eingabe">
			<h:panelGrid id="columns" columns="2">
				<h:outputLabel value="Vorname"
for="vorname" />
				<h:inputText id="vorname"
value="#{customer.vorname}" />
				<h:outputLabel value="Nachname"
for="name" />
				<h:inputText id="name"
value="#{customer.name}" required="true" />
				<h:outputLabel value="Use Credit Card:"
for="useCreditCard" />
				<h:selectBooleanCheckbox
id="useCreditCard"	value="#{customer.useCreditCard}"
	
valueChangeListener="#{customer.useCreditCardChanged}"
					immediate="true"
onclick="this.form.submit()" />
				<h:outputLabel value="Credit Card Type:"
for="ccType" rendered="#{customer.useCreditCard}" />
				<h:inputText
rendered="#{customer.useCreditCard}" id="ccType"
value="#{customer.creditCardType}"
	
required="#{customer.useCreditCard}" />
				<h:outputLabel
rendered="#{customer.useCreditCard}"	value="Credit Card Number:"
for="ccNumber" />
				<h:inputText id="ccNumber"
value="#{customer.creditCardNumber}"
rendered="#{customer.useCreditCard}"
	
required="#{customer.useCreditCard}" />
			</h:panelGrid>
			<h:commandButton action="#{customer.save}"
value="Speichern"
				id="btn_Speichern" />
			<h:commandButton id="cancel" value="Cancel"
immediate="true"
				action="/de/forms/cancelled.xhtml" />
		</h:form>
	</f:view>
</body>
</html>

and the web.xml:
<!-- context Params -->
	<context-param>
		<param-name>javax.faces.PROJECT_STAGE</param-name>
		<param-value>Development</param-value>
	</context-param>
	
	<context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    
    <context-param>
        <param-name>javax.faces.FACELETS_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
	
	<!-- Facelets pages will use the .xhtml extension -->
    <context-param>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>/de/forms/*</param-value>
    </context-param> 

	<!-- filter -->

	<!-- Servlet -->
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
	
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- ServletMapping -->
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.xhtml</url-pattern>
	</servlet-mapping>

If I call the main-page I see the form, so far so good.
But if the first action is fired, for example the checkbox or the submit
button or cancel-button, I get the following error:

HTTP: 404
/<%context%>/forms/jsfForm.jsp not found

Here my question:
Is it possible to use the JSF Forms with all the redirects and forwards
in a JSP environment? I cannot get the form running. 
Do I have to implement the included jsp - files with JSF again?
What would be the best way to build a surrounding file where I can
change the c:import - part with different forms?

Regards
Fabian
                                                                       

Mime
View raw message