On 9/6/05, Rick Reumann <[EMAIL PROTECTED]> wrote:
> 
> I'm sure my Sun JSF book covers this some where but I'm looking over the
> navigation chappers and I'm still not sure how do something REALLY 
> simple...


Yep ... this is ***really*** JSF 101 level stuff.

All I want is a link that will go to "employeesSearch.jsp"


<h:commandLink> is the right answer if you want it to appear as a hyperlink 
(or <h:commandButton> if you want a button). 

Currently employeeSearch.jsp will fire off the prerender because I have
> "employeesSearch" mapped as a managed bean:
> 
> <managed-bean>
> <managed-bean-name>employeesSearch</managed-bean-name>
> 
> <managed-bean-class>net.reumann.EmployeesSearchAction</managed-bean-class>
> <managed-bean-scope>request</managed-bean-scope>
> <managed-property>
> <property-name>employeesListBean</property-name>
> <value>#{employeesListBean}</value>
> </managed-property>
> <managed-property>
> <property-name>employee</property-name>
> <value>#{employee}</value>
> </managed-property>
> </managed-bean>
> 
> So that when index.jps does...
> 
> <jsp:forward page="/employeesSearch.faces"/>


This is not the right answer, because the forward happens in the middle of 
Render Response phase on the calling page, and messes everything up. Don't 
do that :-).

The EmployeesSearchAction prerender fires.
> 
> Now, I just want to have a menu link available that also will go to this
> 'employeeSearch.jsp' page. I know I can get it to work if I create a
> commandLink and make a method in EmployeeSearchAction for it to call
> (used to be setUpForSearch), but now since I'm using prerender I don't
> need that method anymore but I'm having a 'duh' moment on how to create
> the stinkin link that will get to me employeeSearch.jsp? I tried...
> 
> <h:outputLink value="employeesSearch.jsp">
> <h:outputText value="Search"/>
> </h:outputLink>
> 
> But that didn't work:( I'm not surprised it didn't since I didn't see it
> generate the web context name, which makes sense since I'm guessing that
> tag is used more for creating verbatim links and it doesn't trigger the
> JSF life cycle.
> 
> I've tried using commandLink in different ways and think that is really
> what I'm supposed to be using but I can't seem to get that working
> correctly either for this scenario.
> 
> TIA, I know I'm just being an idiot here.


In index.jsp:

<h:commandLink action="search">
<h:outputText value="Search"/>
</h:commandLink>

In your faces-config.xml file, define a navigation rule that maps outcome 
"search" to "/employeeSearch.jsp".

Alternatively, you could do this:

<h:commandLink action="#{index.search}">
<h:outputText value="Search"/>
</h:commandLink>

and map the link to an action method that might (say) return different 
outcomes dynamically based on who the user is, or whatever. But for simple 
static navigation, using a literal String to define the outcome used for 
navigation is the simplest. (Essentially the same principles apply with 
<h:commandButton> if you want a button instead of a hyperlink).

You should really really really work through some of the available JSF 
tutorials on how to do the simple stuff like this. Shale architecture 
questions are on topic here, but JSF basics questions aren't.

--
> Rick


Craig

Reply via email to