• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

How to pass user defined objects as parameter

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to pass user defined objects to the managed bean. I have a page where i get an object after querying database. In the same page i have a link which links to another page. The other page uses the same object details. So i dont want to query the database again, instead i want to make use of the object that i already have with me.

I tried using f:param inside the commandlink which did not address my problem. I learnt that we can pass only strings using f:param.
So please suggest me if there is any other way to achieve my objective.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sankar Yadalam wrote:Hi,

I want to pass user defined objects to the managed bean.


Uhm, "user defined objects" sounds a bit silly. I think you rather mean non-String typed Java objects like Javabeans, DTO´s, VO´s and so on.


I have a page where i get an object after querying database. In the same page i have a link which links to another page. The other page uses the same object details. So i dont want to query the database again, instead i want to make use of the object that i already have with me.

I tried using f:param inside the commandlink which did not address my problem. I learnt that we can pass only strings using f:param.
So please suggest me if there is any other way to achieve my objective.


You know, the HTML response is one big String. The request parameters are Strings. You can only output and take Strings. Thanks to EL, JSF supports "automagic" coercion between String and Number or Boolean, dependent of the property type. But for any other object types you need to implement a custom javax.faces.convert.Converter which converts between String (or Number) and the desired Object type.

Alternatively you can store the desired object instance in session, but that has more impact. Better is to use Tomahawk´s t:saveState tag for this.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic