Concerning my question 2 with the include file removing the from-view-id did the trick - well that coupled with me fixing the typo - I didn't realize that I had a verabtim tag around the wrong section. (Surprised it actually ran ok the way it was without throwing a syntax error.)
Regardless, all seems well now and my frustration (for the moment:) has subsided. I feel like I'm back to square one like I was when I first started with Struts and you start cursing at the computer because you can't figure out why things aren't working as you expect:)
Heath Borders wrote the following on 1/11/2005 3:56 PM:
1. On each commandLink or commandButton, you have two things you can specify: action and actionListener. The actionListener gets called after the link is clicked and all your data successfully updates to your managed beans. It executes the business logic you need. The action you specify is passed to your the navigation handler to tell it what page to direct the user to.
In general, you shouldn't need multiple forms on a page for cases like this. You just need different actions for your commandLinks.
2. What we are doing in our app is using stateless navigation cases. What this means is that you can go anywhere from anywhere.
As far as I see it, the <from-view-id> is just a way of defining a namespace for the navigation cases. So, just get rid of the <from-view-id>s and you should be good to go.
On Tue, 11 Jan 2005 15:04:03 -0500, Rick Reumann <[EMAIL PROTECTED]> wrote:
I know this isn't the main list for JSF and my questions below aren't MyFaces related, but this seems to be a more lively list than the yahoo group so maybe someone can help.
My newbie-ness is showing here but I have two questions and the book I own on JSF doesn't seem to provide the answer (or else it does and I just haven't found it).
Question 1:
Take a typical example where you have a menu of links...
View Really Cool Chart Check your account status View Some Amazing Report
When the user clicks on one of these exciting links it needs to invoke some kind of action (in the JSF world I guess this would be a backing bean) so that the proper business logic takes place in the background and you are then forwarded to the proper displaying JSP. Using Struts this was very clean since each link could map to an Action in my struts-config file.
How do I accomplish the above with JSF? Is the easiest to use commandLink and wrap each link in <h:form>..</h:form>? That seems a bit verbose but if that's the typical practice I can deal with it. Remember each link could need to access a totally different object(backing bean.) It seems awkward to have to nest each link inside of <h:form>
Question 2:
This should be simple, but I'm stumped. If I include a menu.jsp file on a page that is basically a bunch of links, how do I set up the faces config file for the from-view-id? Assuming home.jsp includes menu.jsp I can't seem to get the links to work from menu.jsp regardless if I use menu.jsp or home.jsp for the from-view-id. I even tried use the wilcard * and the menu still doesn't work (page compiles and displays links fine, but links do not result in appropriate pages being called). If I move the code out of being an include file and paste it directly into home.jsp the links work fine.
Here are the three relevant files. (using header.jsp insted of menu.jsp for this example. Also, is there a way to avoid all this f:verbatim code in the include file? It sure make sthe code difficult to read and it doesn't seem nice. I should be able to include any files - JSF seems to require me to really edit files that I want to include).
header.jsp (what gets included) ------------ <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <f:verbatim> <h1> </f:verbatim> <h:outputText value="#{msgs.employeeApp}"/> <f:verbatim> </h1> <h:form> <h:commandLink action="#{employeeBacking.setUpForAdd}"><h:outputText value="#{msgs.addEmployee}"/></h:commandLink> <f:verbatim> <div class="spacer"> </div> </f:verbatim> <h:commandLink action="#{employeeBacking.getEmployees}"><h:outputText value="#{msgs.viewEmployees}"/></h:commandLink> </h:form> </f:verbatim>
home.jsp --------- <html> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<f:view> <head> <f:loadBundle basename="net.reumann.messages" var="msgs"/> <title><h:outputText value="#{msgs.employeeApp}"/></title> <link href="main.css" rel="stylesheet" type="text/css"/> </head> <body> <f:facet name="header"> <f:subview id="header"> <c:import url="header.jsp"/> </f:subview> </f:facet> </body> </f:view> </html>
my-faces-config ----------------
<navigation-rule> <from-view-id>???tried several here???</from-view-id> <navigation-case> <from-outcome>toEmployeeForm</from-outcome> <to-view-id>/employeeForm.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>toList</from-outcome> <to-view-id>/employeeList.jsp</to-view-id> </navigation-case> </navigation-rule>
-- Rick

