The easiest way is to do

<h:commandLink action="#{myUser.showMe}" value="show user details" />

We actually use an actionListener method for that. Here is a snippet of our code:

/**
* <p>This method should be called to navigate to detail page
* for this [EMAIL PROTECTED] #getInstance()} in <code>viewMode</code>.</p>
* <p>This handler is made available to the JSP/JSF page in request scope,
* as a variable with name
* [EMAIL PROTECTED] [EMAIL PROTECTED] PersistentBeanHandlerResolver#handlerVariableNameFor(Class) .PersistentBeanHandlerResolver#handlerVariableNameFor(getType())}.
* And we navigate to [EMAIL PROTECTED] #getDetailViewId()}.</p>
* <p>The [EMAIL PROTECTED] #getPersistentBeanType() type} and an [EMAIL PROTECTED] #getInstance()} should
* be set before this method is called.</p>
*
* @post isViewMode(viewMode) ? new.getViewMode().equals(viewMode)
* : new.getViewMode().equals(VIEWMODE_DISPLAY);
* @post RobustCurrent.lookup(RESOLVER.handlerVariableNameFor(getType())) == this;
* @throws FatalFacesException
* getType() == null;
* @throws FatalFacesException
* getInstance() == null;
*
* @mudo (jand) security
*/
public final void navigateHere(String viewMode) throws FatalFacesException {
LOG.debug("InstanceHandler.navigate called; id = " + getId() +
", instance = " + getInstance());
if (getPersistentBeanType() == null) {
LOG.fatal("cannot navigate to detail, because no type is set (" +
this);
}
if (getInstance() == null) {
LOG.fatal("cannot navigate to detail, because no instance is set (" +
this);
}
setViewMode(isViewMode(viewMode) ? viewMode : VIEWMODE_DISPLAY);
// put this handler in request scope, under an agreed name, create new view & navigate
RESOLVER.putInRequestScope(this);
FacesContext context = RobustCurrent.facesContext();
UIViewRoot viewRoot = RobustCurrent.viewHandler().createView(context, getDetailViewId());
context.setViewRoot(viewRoot);
context.renderResponse();
}

We don't use the faces-config navigation. getDetailViewId() returns the (standardized) URL of the jspx page that shows details of persistent beans of this type. This handler has different view modes (display, edit, editNew, deleted).


On 2 Sep 2005, at 10:00, ::SammyRulez:: wrote:

sorry guys but I can't figure out how to pass the commandlink to
identify the right object to the action in the next action in
nevigation..

i save my jsp with dataTable

<f:view>
<html>
<head>
<title></title>
</head>
<body>
<h:form>
<h:dataTable var="myUser" value="#{user.allUsers}" >
<h:column>
<f:facet name="header">
username
</f:facet>

<h:outputText value="#{myUser.name}" />
</h:column>
<h:column>
<f:facet name="header">
action
</f:facet>
<h:commandLink action="#{user.showUserDetail}" >
<f:param name="id" value="#{myUser.id}"/>
<h:outputText value="show user details"/>
</h:commandLink>
</h:column>

</h:dataTable>
</h:form>
</body>
</html>
</f:view>

and my action method

public String showUserDetail(){
setName("pine");
setId(1);
return "ok";

}

and a simple page

<f:view>
<head>
<title>A Simple JavaServer Faces Application</title>
</head>
<body>
<h:form>
<h3>
Welcome to JavaServer Faces,
<h:outputText value="#{user.name}"/>!
</h3>
</h:form>
</body>
</f:view>

I set the navigation as follow

<navigation-rule>
<from-view-id>/userlist.jsp</from-view-id>
<navigation-case>
<from-outcome>ok</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>

the command link do not follow the navigation rule... why?

thanks again

Sam


<x-tad-smaller>Met vriendelijke groeten,

Jan Dockx
</x-tad-smaller><x-tad-smaller>
PeopleWare NV - Head Office</x-tad-smaller>
<x-tad-smaller>
Cdt.Weynsstraat 85
B-2660 Hoboken
Tel: +32 3 448.33.38
Fax: +32 3 448.32.66 </x-tad-smaller>
<x-tad-bigger>
</x-tad-bigger>
<x-tad-smaller>
PeopleWare NV - Branch Office Geel</x-tad-smaller>
<x-tad-smaller>
Kleinhoefstraat 5
B-2440 Geel
Tel: +32 14 57.00.90
Fax: +32 14 58.13.25</x-tad-smaller>
<x-tad-bigger>
</x-tad-bigger>
<x-tad-smaller>
http://www.peopleware.be/
</x-tad-smaller><x-tad-smaller>http://www.mobileware.be/</x-tad-smaller>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to