Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending parameters to another Bean  RSS feed

dana lees
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using a datatable in which I have the following link (on 1 of the table's columns) which navigates to another window:

<h:commandLink action="selectApplicationGroups">
<hutputText value="Groups"></hutputText>
<f:param name="appID" value="#{}"></f:param>
<f:param name="appName" value="#{}"></f:param>

On the destination JSP I retreive the parameters and show them in the header

<h2>Select groups for application '<hutputText value="#{param.appID}" />'</h2>
<h:selectManyCheckbox id="groups" value="#{groupDAO.selectedItems}" layout="pageDirection">
<f:selectItems value="#{groupDAO.selectItems}"/>

I have a java class (groupDAO) in which I need to use the 'appID' parameter:

How can I retreive the value of AppID in the groupDAO class?

Thank you,
Tim Holloway
Posts: 18705
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Dana!

I'll approach this in 2 parts. First, a comment about the DAO.

A true DAO is a service component. You wouldn't normally access it directly from the view. Instead the backing bean would probably use the DAO internally to build a model and to update the persistent store with the results (by writing back through the DAO).

As to the more immediate question, JSF is heavily based on injection. You basically define the app as a set of JavaBeans and then use mechanisms such as the faces-config file to wire them together.

In my most recent apps, I use the Spring Framework to construct the DAOs and inject them into the JSF backing beans or other business-layer objects. Spring and faces-config both have the ability to construct and wire together javabeans, but there are certain cases where one or the other works better for what's needed.

In any event, once the framework has injected the DAO into my business bean, that bean can use the DAO to build the datamodels that end up attached to the JSF view.

I know that seems complicated, but the tradeoff here is lots of simple, easy-to-understand objects working together instead of one big confusing lump.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!