CommandLink not invoking the action method

Hi,

I have commandLink that doesn't call the action method specified in the managed bean. I also have scope of the bean as session. I tried with commandButton also. Any thoughts on this? I am using myfaces1.1.4.

The source code is as follows:

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

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

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<html>

<f:subview id="itemdetails">

<f:loadBundle basename="messages" var="msgs"/>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Item Details</title>

<LINK REL=StyleSheet HREF="buttons.css" TYPE="text/css" />

</head>

<body bgcolor="#DEE7F7">

<h:form>

<h:commandLink action="#{ItemDetailsBean.addItems}" styleClass="label" value="Add" />

<h:panelGrid id="panel" columns="4" border="0" styleClass="tableborder" style="text-align:left">

<f:facet name="header">

<h:outputText value="Item Details" styleClass="title" />

</f:facet>

<h:outputLabel value="#{msgs.line}" styleClass="label"/>

<h:panelGroup>

<h:column>

<h:inputText id="lineNumber" value="#{ItemDetailsBean.lineNumber}" required="false" />

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.elApplicationTypeJapan}" styleClass="label"/>

<h:inputText id="elApplicationTypeJapan" value="#{ItemDetailsBean.elApplicationTypeJapan}" required="false" />

<h:outputLabel value="#{msgs.ro}" styleClass="label" />

<h:panelGroup>

<h:column>

<h:inputText id="roNumber" value="#{ItemDetailsBean.roNumber}" required="false" />

<h:outputText escape="false" value="<br>" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.elApplicationTypeNotJapan}" styleClass="label"/>

<h:inputText id="elApplicationTypeNotJapan" value="#{ItemDetailsBean.elApplicationTypeNotJapan}" required="false" />

<h:outputLabel value="#{msgs.item}" styleClass="mandatory"/>

<h:panelGroup>

<h:column>

<h:inputText id="itemNumber" value="#{ItemDetailsBean.itemNumber}" required="true" />

<h:graphicImage id="itemDescLov" value="#{msgs.imagesLov}" style="cursor:hand"/>

<h:inputText id="itemDesc" value="#{ItemDetailsBean.itemDesc}" required="true" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.elModelType}" styleClass="label"/>

<h:inputText id="elModelType" value="#{ItemDetailsBean.elModelType}" required="false" />

<h:outputLabel value="#{msgs.uom}" styleClass="mandatory"/>

<h:panelGroup>

<h:column>

<h:inputText id="uomCode" value="#{ItemDetailsBean.uomCode}" required="true" />

<h:graphicImage id="uomCodeLov" value="#{msgs.imagesLov}" style="cursor:hand"/>

<h:inputText id="uomDesc" value="#{ItemDetailsBean.uomDesc}" required="true" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.elApprovalNumber}" styleClass="label"/>

<h:inputText id="elApprovalNumber" value="#{ItemDetailsBean.elApprovalNumber}" required="false" />

<h:outputLabel value="#{msgs.qty}" styleClass="mandatory"/>

<h:panelGroup>

<h:column>

<h:inputText id="quantity" value="#{ItemDetailsBean.quantity}" required="true" />

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.ordinanceCodeNo}" styleClass="label"/>

<h:inputText id="ordinanceCode" value="#{ItemDetailsBean.ordinanceCode}" required="false" />

<h:outputLabel value="#{msgs.qtyperunitprice}" styleClass="mandatory"/>

<h:panelGroup>

<h:column>

<h:inputText id="quantityPerUnitPrice" value="#{ItemDetailsBean.quantityPerUnitPrice}" required="true" />

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.ordinanceClassficationNumber}" styleClass="label"/>

<h:inputText id="ordinanceClassficationNumber" value="#{ItemDetailsBean.ordinanceClassficationNumber}" required="false" />

<h:outputLabel value="#{msgs.unitprice}" styleClass="mandatory"/>

<h:panelGroup>

<h:column>

<h:inputText id="unitPrice" value="#{ItemDetailsBean.unitPrice}" required="true" />

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.smallSum}" styleClass="label"/>

<h:inputText id="smallSum" value="#{ItemDetailsBean.smallSum}" required="false" />

<h:outputLabel value="#{msgs.hsCode}" styleClass="mandatory" />

<h:panelGroup>

<h:column>

<h:inputText id="hsCode" value="#{ItemDetailsBean.hsCode}" required="false" />

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.secretCodeFlag}" styleClass="label"/>

<h:inputText id="secretCodeFlag" value="#{ItemDetailsBean.secretCodeFlag}" required="false" />

<h:outputLabel value="#{msgs.countryoforigin}" styleClass="label"/>

<h:panelGroup>

<h:column>

<h:inputText id="countryOfOrigin" value="#{ItemDetailsBean.countryOfOrigin}" required="false" />

<h:graphicImage id="countryOfOriginLov" value="#{msgs.imagesLov}" style="cursor:hand"/>

<h:inputText id="countryOfOriginDesc" value="#{ItemDetailsBean.countryOfOriginDesc}" required="false" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.comprehensivePreInspectionFlag}" styleClass="label"/>

<h:inputText id="comprehensivePreInspectionFlag" value="#{ItemDetailsBean.comprehensivePreInspectionFlag}" required="false" />

<h:outputLabel value="#{msgs.countryofdiffusion}" styleClass="label"/>

<h:panelGroup>

<h:column>

<h:inputText id="countryOfDiffusion" value="#{ItemDetailsBean.countryOfDiffusion}" required="false" />

<h:graphicImage id="countryOfDiffusionLov" value="#{msgs.imagesLov}" style="cursor:hand"/>

<h:inputText id="countryOfDiffusionDesc" value="#{ItemDetailsBean.countryOfDiffusionDesc}" required="false" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.ear}" styleClass="label"/>

<h:inputText id="ear" value="#{ItemDetailsBean.ear}" required="false" />

<h:outputLabel value="#{msgs.countryofassembly}" styleClass="label"/>

<h:panelGroup>

<h:column>

<h:inputText id="countryOfAssembly" value="#{ItemDetailsBean.countryOfAssembly}" required="false" />

<h:graphicImage id="countryOfAssemblyLov" value="#{msgs.imagesLov}" style="cursor:hand"/>

<h:inputText id="countryOfAssemblyDesc" value="#{ItemDetailsBean.countryOfAssemblyDesc}" required="false" />

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.tsca}" styleClass="label"/>

<h:inputText id="tsca" value="#{ItemDetailsBean.tsca}" required="false" />

<h:outputLabel value="#{msgs.hazardousgoods}" styleClass="label"/>

<h:panelGroup>

<h:column>

<h:selectBooleanCheckbox id="hazardousGoods" value="#{ItemDetailsBean.hazardousGoods}"/>

<h:outputText escape="false" value="<br>"/>

</h:column>

</h:panelGroup>

<h:outputLabel value="#{msgs.inspection}" styleClass="label"/>

<h:inputText id="inspection" value="#{ItemDetailsBean.inspection}" required="false" />

<h:outputText escape="false" value="<br>"/>

<h:outputText escape="false" value="<br>"/>

<h:outputLabel value="#{msgs.ewarningGoods}" styleClass="label"/>

<h:inputText id="warningGoods" value="#{ItemDetailsBean.warningGoods}" required="false" />

</h:panelGrid>

</h:form>

</body>

</f:subview>

</html>

[8778 byte] By [prashantp_4sa] at [2007-11-26 22:30:00]
# 1
Probably you got error messages on the page. Put <h:messages /> to chech.
amitteva at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
The CommandLink works if i the jsf page is enclosed within <f:view>. However it doesn't work for <f:subview>. And my jsf page has to be under<f:subview> only since i am including it in another page.Any work around for this plz?
prashantp_4sa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Include pages should not be written as standalone pages. Remove the head and the body. Keep them in the parent page.
BalusCa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

thanks. That solved my problem but i am facing with new one.

my url looks like this:

http://localhost:8080/viewLayer/ExportInvoiceEdit.faces?invoiceId=INV-00035&orgId=PLGA

On clicking the command link, the action is getting invoked . and the page gets redisplayed with url : http://localhost:8080/viewLayer/ExportInvoiceEdit.faces

So how do i append the params so that on clicking the commandlink, the user sees the same page again.

Note: ExportInvoiceEdit.faces consists of tabs

prashantp_4sa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Add them as f:param in commandlink. Also see http://balusc.xs4all.nl/srv/dev-jep-com.html
BalusCa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Balu, I already tried using f:param. Here is the code snippet

<%

invoiceId = (String)request.getAttribute("invoiceId");

orgId = (String)request.getAttribute("orgId");

%>

<h:commandLink actionListener="#{ItemDetailsBean.addItems}" styleClass="label" value="Save">

<f:param name="invoiceId" value="#{invoiceId}"/>

<f:param name="orgId" value="#{orgId}" />

</h:commandLink>

When i move the mouse over the commandlink, it shows the complete url but when i click the commandlink, the url is again:

http://localhost:8080/viewLayer/ExportInvoiceEdit.faces

without the param values

prashantp_4sa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Attributes? Those ought to be parameters.Anyway, are those params defined in the faces-config.xml?
BalusCa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

I have a SummaryPage that has an outputlink. On clicking that link to goes to the following URL:

http://localhost:8080/viewLayer/ExportInvoiceEdit.faces?invoiceId=INV-00035&orgId=PLGA

The code snippet of this page is :

<t:panelTabbedPane width="110%" activeTabStyleClass="RightTabForeCurveid704112siteid0" >

<t:panelTab label="Invoice Header">

<jsp:include flush="true" page="invoiceheader.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Item Summary" >

<jsp:include flush="true" page="ItemSummary.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Item Edit">

<jsp:include flush="true" page="itemdetails.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Item Specification">

<jsp:include flush="true" page="itemspecification.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Comments">

<jsp:include flush="true" page="comments.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Shipping Schedule">

<jsp:include flush="true" page="ScheduleSummary.jsp"></jsp:include>

</t:panelTab>

<t:panelTab label="Add Shipping Schedule" >

<jsp:include flush="true" page="seaschedule.jsp"></jsp:include>

</t:panelTab>

</t:panelTabbedPane>

===================

In itemdetails.jsp, I have the commandlink. I don;t have any params configured in faces-config.xml since there is not managed bean for ExportInvoiceEdit.faces. However i have one managed bean for each included jsf page

I need the invoiceid that has been passed in url in all the included jsf pages. Since on commandlink click, the page is getting refreshed without the param "飊voiceid", my tabs that contain included jsf pages r getting displayed blank on refresh.

Message was edited by:

prashantp_4s

prashantp_4sa at 2007-7-10 11:34:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...