This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSF and the fly likes Parameter Passing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Parameter Passing" Watch "Parameter Passing" New topic
Author

Parameter Passing

Awais Sheikh
Ranch Hand

Joined: Jun 07, 2006
Posts: 48
I have a main page named as main.jsp. Main page has 5 links, all links points to same page but sends different parameters i.e.
for home page I am using main.jsp?cid=1
for login page I am using main.jsp?cid=2
etc etc. This was previously I was doing in JSP and using request.getParameter("cid") and it was working fine. Now, In JSF application I am trying to manage everything by MBeans. Please guide me how can I send Parameters to the MBean? or Some suitable link?? I 'll be very much thankful to you.
Marko Zivanovic
Greenhorn

Joined: Jul 03, 2006
Posts: 1
How do you specify links? If you're using commandLink or commandButton components you can add <f : param name="name" value="value"> sub-elements. Then, on the server, in your actionHandler, you can extract those values and do what you need with them. Generaly, JSF is not really page-centric ... you should start thinking MVC-style . You pass some parameters to controller, controller updates model state and view renders that new state.

My answer is pretty general, but, so is your question . Anyway, I hope it helps. If you need more specific answer, post more details.
[ July 03, 2006: Message edited by: marko.zivanovic ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

"marko.zivanovic"

Welcome to the JavaRanche and thanks for your advice. We don't have a lot of rules here, but we would appreciate it if you'd change your display name to honor our Naming Policy. You'll be OK if you just remove the dot (that is, "marko zivanovic" instead of "marko.zivanovic"). Thanks!


Customer surveys are for companies who didn't pay proper attention to begin with.
Awais Sheikh
Ranch Hand

Joined: Jun 07, 2006
Posts: 48
Thanks for your reply.
I am showing links on my page in this way.


I just want as I click on this link value of a property dt.sendMsg sets to '1' and by clicking 2nd dt.sendMsg sets to '2'. So, according to your post it can be done using <f:param. am I right??
If I am not bothering you can you please post a sample example.
Thanks a lot for your kind response.
Sajan Patel
Ranch Hand

Joined: Oct 25, 2004
Posts: 77
You should be able to use main.jsp?cid=1 and in your handler you can get that value for CID. But remember this is mixure of JSF and normal Response/Request.

If you want you can use following



Above both requests are JSF request so you have to get value from JSF request.

Awais Sheikh
Ranch Hand

Joined: Jun 07, 2006
Posts: 48
Sajan Patel thank for your reply.

Now, after Sajan's post I have an idea that how to implement this but please let me know what does "#{myHandler.showMy}" will contain?? does it contain any page name?? or it is refering to any event handler?? should i have to write a event handler for this ??
Sajan Patel
Ranch Hand

Joined: Oct 25, 2004
Posts: 77
action="#{myHandler.showMy}"

"myHandler" is a managed bean which is defined faces-config and "showMy" is one of method of that java class.

faces-config.xml


My friend I would like to tell you politely that please refer some documents to understand JSF and its TAG. If you want you can start from here
http://java.sun.com/javaee/javaserverfaces/1.1/docs/tlddocs/ >> Go to H tag >> go to commandLink >> and check out what Action attribute is of ommandLink
tag.
Aysther Evenstar
Greenhorn

Joined: Nov 04, 2009
Posts: 1
You can use the new JSF2 tag f:pageParam within the f:metadata tag in order to pull out request parameters.

Or, if you need Pretty bookmarkable URLs, you can use PrettyFaces - SEO, Dynamic Parameters, Pretty Urls, and Navigation for JSF/JSF2
 
wood burning stoves
 
subject: Parameter Passing