Problems in tag <h:commandLink>

i use this tag in the test.jsp like this:

<h:commandLink action="details">

<h:outputText value="Details" />

</h:commandLink>

faces-config.xml like this:

<navigation-rule>

<from-view-id>test.jsp</from-view-id>

<navigation-case>

<from-outcome>details</from-outcome>

<to-view-id>details.jsp</to-view-id>

<redirect />

</navigation-case>

But when i click "Details",the routing doesn't work.

if i change the tag <h:commandLink> into <h:commandButton> like this:

<h:commandButton value="Details" action="details" />

then it works.

What's the problem with the tag <h:commandLink>?

[779 byte] By [LeoArchera] at [2007-10-2 15:37:03]
# 1
Try <h:commandLink action="details" value="Details" />btw the command links are little buggy
amitteva at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
try to put immediate="true" in the commandLink
pringia at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I adjusted the tag like this:

<h:commandLink action="details" value="Details" immediate="true">

but it still doesn't work.

I have writen a header.jsp, in this file , i use the tag like this :

<h:commandLink action="inbox" immediate="false" rendered="true">

<h:graphicImage url="/images/alert_01.jpg" styleClass="header-icon"

alt="Inbox" />

<h:outputText value="Inbox" styleClass="header-command"/>

</h:commandLink>

when i include this file into another file , the tag <h:commandLink> works.

But if i use the header.jsp separately, the tag doesn't work.

Is this a bug?

LeoArchera at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Can you put here the complete example?
pringia at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

this is the example from "Java Server Face in Action"

<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>

<html>

<head>

<title>

<h:outputText value="ProjectTrack - Inbox" />

</title>

<link rel="stylesheet" type="text/css" href="../stylesheet/stylesheet.css" />

</head>

<body class="page-background">

<jsp:include page="header.jsp"/>

<h:form>

<h:panelGrid headerClass="page-header" styleClass="table-background"

columns="1" cellpadding="5">

<f:facet name="header">

<h:outputText value="Inbox -approve or reject projects" />

</f:facet>

<h:outputText value="Application messages."

styleClass="errors" />

<h:panelGrid columns="6" styleClass="table-background"

rowClasses="table-odd-row,table-even-row"

cellpadding="3">

<h:commandLink styleClass="table-header">

<h:outputText value="Project name" />

</h:commandLink>

<h:commandLink styleClass="table-header">

<h:outputText value="Type" />

</h:commandLink>

<h:commandLink styleClass="table-header">

<h:outputText value="Status" />

</h:commandLink>

<h:panelGroup/>

<h:panelGroup/>

<h:panelGroup/>

<h:outputText value="Inventory Manager v2.0"/>

<h:outputText value="Internal Desktop Application" />

<h:outputText value="Requirements/Analysis" />

<h:commandButton action="approve" value="Approve" >

</h:commandButton>

<h:commandLink action="reject">

<h:outputText value="Reject" />

</h:commandLink>

<h:commandLink action="details">

<h:outputText value="Details" />

</h:commandLink>

<h:outputText value="TimerTracker"/>

<h:outputText value="Internal Web Application" />

<h:outputText value="Requirements/Analysis" />

<h:commandLink action="approve" value="Approve" immediate="true">

</h:commandLink>

<h:commandLink action="reject">

<h:outputText value="Reject" />

</h:commandLink>

<h:commandLink action="details">

<h:outputText value="Details" />

</h:commandLink>

</h:panelGrid>

</h:panelGrid>

</h:form>

</body>

</html>

</f:view>

LeoArchera at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I run your code a made a few changes try it a see if it works.

Page 1

<?xml version='1.0' encoding='windows-1252'?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"

xmlns:h="http://java.sun.com/jsf/html"

xmlns:f="http://java.sun.com/jsf/core">

<jsp:text>

<![CDATA[ ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> ]]>

</jsp:text>

<jsp:directive.page contentType="text/html;charset=windows-1252"/>

<f:view>

<html>

<head>

<title>

<h:outputText value="ProjectTrack - Inbox"/>

</title>

<link rel="stylesheet" type="text/css"

href="../stylesheet/stylesheet.css"/>

</head>

<body class="page-background"><h:messages showDetail="true"/><h:form>

<h:panelGrid headerClass="page-header" styleClass="table-background"

columns="1" cellpadding="5">

<f:facet name="header">

<h:outputText value="Inbox -approve or reject projects"/>

</f:facet>

<h:outputText value="Application messages." styleClass="errors"/>

<h:panelGrid columns="6" styleClass="table-background"

rowClasses="table-odd-row,table-even-row"

cellpadding="3">

<h:commandLink styleClass="table-header">

<h:outputText value="Project name"/>

</h:commandLink>

<h:commandLink styleClass="table-header">

<h:outputText value="Type"/>

</h:commandLink>

<h:commandLink styleClass="table-header">

<h:outputText value="Status"/>

</h:commandLink>

<h:panelGroup/>

<h:panelGroup/>

<h:panelGroup/>

<h:outputText value="Inventory Manager v2.0"/>

<h:outputText value="Internal Desktop Application"/>

<h:outputText value="Requirements/Analysis"/>

<h:commandButton action="approve" value="Approve"></h:commandButton>

<h:commandLink action="reject">

<h:outputText value="Reject"/>

</h:commandLink>

<h:commandLink action="details">

<h:outputText value="Details"/>

</h:commandLink>

<h:outputText value="TimerTracker"/>

<h:outputText value="Internal Web Application"/>

<h:outputText value="Requirements/Analysis"/>

<h:commandLink action="approve" value="Approve" immediate="true"></h:commandLink>

<h:commandLink action="reject">

<h:outputText value="Reject"/>

</h:commandLink>

<h:commandLink action="details">

<h:outputText value="Details"/>

</h:commandLink>

</h:panelGrid>

</h:panelGrid>

</h:form></body>

</html>

</f:view>

</jsp:root>

Faces config

<?xml version="1.0" encoding="windows-1252"?>

<!DOCTYPE faces-config PUBLIC

"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"

"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config xmlns="http://java.sun.com/JSF/Configuration">

<navigation-rule>

<from-view-id>/untitled1.jspx</from-view-id>

<navigation-case>

<from-outcome>details</from-outcome>

<to-view-id>/untitled2.jsp</to-view-id>

<redirect/>

</navigation-case>

<navigation-case>

<from-outcome>approve</from-outcome>

<to-view-id>/untitled2.jsp</to-view-id>

<redirect/>

</navigation-case>

<navigation-case>

<from-outcome>reject</from-outcome>

<to-view-id>/untitled3.jsp</to-view-id>

<redirect/>

</navigation-case>

</navigation-rule>

</faces-config>

pringia at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

<navigation-rule>

<from-view-id>/test.jsp</from-view-id>

<navigation-case>

<from-outcome>details</from-outcome>

<to-view-id>/details.jsp</to-view-id>

<redirect />

</navigation-case>

try it

yanghuwa at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Hi, i have the same problems with h:commandLink component. Did you find any solution for that?
checo1109a at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Is javascript enabled in your browser? If it isn't then enable it and try again.
rlubkea at 2007-7-13 15:15:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...