This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

commandLink param problem  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSF application in which I want to use h:commandLink and f:param tags. The commandLink on it's own works but as soon as I add the f:param tag, the link no longer works.

I found an example that seems to work correctly: http://www.javabeat.net/tips/44-hcommandlink-how-to-pass-parameter-to-next.html. When I create a new project in NetBeans, and use the files from the example, it works.

However when I create these same files within my own application in NetBeans 6.5 (via "File->New File->Web->JSP" and "File->New->Java->Java Class"), then copying the example code into the new pages, and the relevant faces-config.xml section to my own faces-config.xml file, the commandLink no longer works. The obvious conclusion is that there's something different in my own application that's affecting the way the code is supposed to work.

In looking at the HTML source code generated, and comparing the working example with my non-working implementation of the same code, I found that the working version contains generated javascript, and the non-working version contains no generated javascript.

Seemingly, the reason my implementation does not work is that the javascript is missing.

My question is this:
Is this a NetBeans thing issue do you think? If so, how do I tell NetBeans to generate the javascript for the commandLink tag?

Thanks
-bob


The JSP source code:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

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

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

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

<html>
<body>
<f:view>
<h:form id="commandLink">
<h:commandLink value="Test Link" action="#{commandLinkBean.linkIt}">
<f:param name="param1" value="ParamValue1" />
<f:param name="param2" value="ParamValue2" />
</h:commandLink>
</h:form>
</f:view>
</body>
</html>



******** Example faces.config.xml ***************************************************
<?xml version='1.0' encoding='UTF-8'?>
<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

<managed-bean>
<managed-bean-name>
commandLinkBean
</managed-bean-name>
<managed-bean-class>
com.webfront.CommandLinkBean
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
<managed-property>
<property-name>param1</property-name>
<value>#{param.param1}</value>
</managed-property>
<managed-property>
<property-name>param2</property-name>
<value>#{param.param2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>
commandLink
</from-outcome>
<to-view-id>
/CommandLinkResults.jsp
</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>


********** My Application's faces.config.xml *******************************************
<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<!-- Test stuff -->
<managed-bean>
<managed-bean-name>
commandLinkBean
</managed-bean-name>
<managed-bean-class>
com.webfront.CommandLinkBean
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
<managed-property>
<property-name>param1</property-name>
<value>#{param.param1}</value>
</managed-property>
<managed-property>
<property-name>param2</property-name>
<value>#{param.param2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>
commandLink
</from-outcome>
<to-view-id>
/CommandLinkResults.jsp
</to-view-id>
</navigation-case>
</navigation-rule>
<!-- end of Test stuff -->

<managed-bean>
<managed-bean-name>app</managed-bean-name>
<managed-bean-class>com.webfront.ApplicationBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>ses</managed-bean-name>
<managed-bean-class>com.webfront.SessionBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>req</managed-bean-name>
<managed-bean-class>com.webfront.RequestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>totes</managed-bean-name>
<managed-bean-class>com.webfront.controllers.ToteController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>inventory</managed-bean-name>
<managed-bean-class>com.webfront.controllers.InventoryController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>categories</managed-bean-name>
<managed-bean-class>com.webfront.controllers.CategoryController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
<managed-property>
<property-name>selectedCat</property-name>
<value>#{param.selectedCat}</value>
</managed-property>
</managed-bean>

<!-- Menu navigation rules -->
<navigation-rule>
<navigation-case>
<from-outcome>totesList</from-outcome>
<to-view-id>/ToteListing.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>toteContents</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>itemSearch</from-outcome>
<to-view-id>/InventoryItem.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>catEntry</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<!-- Totes pages navigation rules -->
<navigation-rule>
<from-view-id>/ToteListing.jsp</from-view-id>
<navigation-case>
<from-action>#{totes.newTote}</from-action>
<from-outcome>ok</from-outcome>
<to-view-id>/ToteForm.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/ToteForm.jsp</from-view-id>
<navigation-case>
<from-action>#{totes.cancel}</from-action>
<from-outcome>cancel</from-outcome>
<to-view-id>/ToteListing.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/ToteContents.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.edit}</from-action>
<from-outcome>edit</from-outcome>
<to-view-id>/InventoryItemEdit.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

<!-- Inventory pages navigation rules -->
<navigation-rule>
<from-view-id>/InventoryItem.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.search}</from-action>
<from-outcome>ok</from-outcome>
<to-view-id>/InventorySearch.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/InventorySearch.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.reset}</from-action>
<from-outcome>reset</from-outcome>
<to-view-id>/InventoryItem.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/InventoryItemEdit.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.update}</from-action>
<from-outcome>update</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-action>#{inventory.cancel}</from-action>
<from-outcome>cancel</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

<!-- Categories navigation -->
<navigation-rule>
<from-view-id>/Categories.jsp</from-view-id>
<navigation-case>
<from-action>#{categories.addCategory}</from-action>
<from-outcome>added</from-outcome>
<to-view-id>/CategoryForm.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/CategoryForm.jsp</from-view-id>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
</navigation-case>
</navigation-rule>

</faces-config>
 
Greenhorn
Posts: 15
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you perhaps post instructions on how to set up you project? I tried to replicate it in my NetBeans, but didn't get far - if I copy the jsp code into a new "Visual JSF page" or something like that, I just get "markup preceding the root ... must be well-formed" and I didn't know where to put the faces.config.xml
 
Bob Little
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Samuel Goldschmidt wrote:Could you perhaps post instructions on how to set up you project? I tried to replicate it in my NetBeans, but didn't get far - if I copy the jsp code into a new "Visual JSF page" or something like that, I just get "markup preceding the root ... must be well-formed" and I didn't know where to put the faces.config.xml



Hello Samuel,

I believe, as you do, that my problem has more to do with how I set up the project initially than it does with a syntax error or incorrect usage.

I found that the non-working implementation had references to both Standard JSF and Visual Web JSF frameworks. The new, working version of the project has only the standard JSF framework referenced. I think there may likely be a conflict when both frameworks are referenced in a project.

I've created a new project, and added all the components from the previous one to the new one and my commandLink is now working as it should. Anyway, the problem seems solved now.

Thanks for your input Samuel!

-bob
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!