Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter Passing

 
Awais Sheikh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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!
 
Awais Sheikh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic