En l'instant précis du 01/29/07 14:54, sammes s'exprimait en ces termes:
> Hi,
>
> I developed this simple "a dogs life" jsf application.
> There I have 3 jsp´:
> index.jsp (which redirects to enterAge.jsp)
> enterAge.jsp
> result.jsp
> error.jsp
>
> Now, when I call localhost:8080/jsf/index.jsf -> it shows the enterAge.jsp,
> which is:
>
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h" %>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>
> <html>
>   <head>
>     <title>A dog's life</title>
>   </head>
>   <body>
>     <f:view>
>       <h:form>
>         <h:outputText value="Enter your age please"/>
>         <h:inputText value="#{dog.age}" />
>          <h:commandButton value="Calculate Dog Years"
>           action="#{dog.calcYears}" />
>       </h:form>
>     </f:view>
>   </body>
> </html>
>   
I suppose from remaining of email, that you mean the html resulting from
the above jsp is shown, not the jsp content unparsed.
> In the browser, the url is still index.jsf (?).
>   
Internal server redirect, the url is not changed because client is not
aware of this redirect.
> But it shows the content of enterAge.jsp
> When I now enter a number and press calculate, the page still occures and
> nothing happens except a reload I think.
>   
It seems your form is submitting to 'index.jsf' instead of 'enterAge.jsf'
> When I directly call the enterAge.jsf in the browser url, tghe same page
> occurs as before, but when I now click on the button, the page goes to the
> result.jsp (but still shows "enterAge.jsp" in the browser) and shows the
> result (entered number divided by 7).
>   
This part is normal. Your jsf form was submitted to enterAge.jsf. That's
why you see enterAge.jsf in url. However, after action execution, jsf
got instructed to display content of result.jsp (according to navigation
rules) and that's what it does.
> Why doesnt this wirk when I call the index.jsp (which redirects to
> enterAge.jsp - do I have to redirect to enterage.JSF? I do taht via
> jsp:forward) ?
>   
jsp:forward is all internal. In general, jsp tags do not mix very well
with jsf :) In your case you are under a jsf context (you accessed
index.jsf) which then write down a few datas (like the viewId=index.jsp)
before asking the index.jsp to render, which itself redirect work
enterAge.jsp, but for JSF, this is the index.jsf view, and that's where
the submit will go, and that's where the navigation rules will be looked
for.

solution, do the opposite,
access index.jsp, which forwards to enterAge.jsf, which jsf handle and
write down the viewId (enterAge.jsp) before asking enterAge.jsp to render.
> What I also see, is that when I click the button, a very short time a
> javascript error will be shown in the bottom of the browser window.
>
> The HTML code of the "compiled" index.jsp is this here:
>       <form id="_idJsp0" name="_idJsp0" method="post"
> action="/dss/jsf/index.jsf" enctype="application/x-www-form-urlencoded">
>         Enter your age please
>         <input id="_idJsp0:_idJsp2" name="_idJsp0:_idJsp2" type="text"
> value="7" />
>          <input id="_idJsp0:_idJsp3" name="_idJsp0:_idJsp3" type="submit"
> value="Calculate Dog Years"
> onclick="clear__5FidJsp0();document.forms['_idJsp0'].elements['autoScroll'].value=getScrolling();"
> />
>       <input type="hidden" name="_idJsp0_SUBMIT" value="1" />
> <input type="hidden" name="autoScroll" />
> <input type="hidden" name="jsf_sequence" value="25" /><input type="hidden"
> name="_idJsp0:_link_hidden_" /><script type="text/javascript"><!--
> function clear__5FidJsp0() {
>   var f = document.forms['_idJsp0'];
>   f.elements['_idJsp0:_link_hidden_'].value='';
>   f.target='';
> }
> clear__5FidJsp0();
> //--></script></form>
>
> HERE the action is ".../index.jsf". This is false, becuase index.jsp does
> only redirect.
>
> When I have a look at the compiled HTML of the page, if I call enterAge.jsf
> directly, i see that the action is .../enterAge.jsf instead of .../index.jsf
>
> 1. Where is the problem ?
>
> 2. Second question: What do I have to do in my web.xml when calling the jsf
> pages without typing in the name of the jsp ?
> I have the folder [webroot]/jsf/[here are my jsf pages (*.jsp)].
> When I cal localhost:8080/jsf/ > I get an 
>
> ERROR [javax.faces.webapp.UIComponentTag] Faces context not found.
> getResponseWriter will fail.
>
> If I call localhost:8080/jsf/index.jsf-> I get the page.
>
> I begin to develop jsf, but I much some problems with that in my
> jboss/tomcat environment.
>
> Could anyone help ?
>
> Could any post a good web.xml for me ?
>
> How do I have to define the filter/filtermapping/servlet/servlet-mapping
> that all pages under "/jsf" will be used for jsf ?
>
> best regards
> sammes
>   

Reply via email to