wood burning stoves*
The moose likes JSF and the fly likes Another parameter passing noob Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Another parameter passing noob" Watch "Another parameter passing noob" New topic

Another parameter passing noob

Jason A Wong

Joined: Dec 10, 2012
Posts: 4
Hiyas, I've browsed through several posts related to parameter passing, and I'm still quite lost.

What I'm trying to do is:

1) Getting the input string value from 1st JSF page
2) Have the bean process it and launch 2nd JSF page
2) Pass to 2nd JSF page and commandLink to 3rd JSF page
3) Pass to 3rd JSF page
4) Use string value in bean related to 3rd JSF page

I kind of made up a simple code of what I wanted. From what I think, JSF Page 2 is able to read the pass string from JSF Page 1 is because the bean launches JSF Page 2.
But from JSF page 2, I'm unsure on how to assign the value in order to pass into JSF Page 3.
If I came off as confusing, I am sorry.
Much appreciated.

JSF Page 1

JSF Page 2

Pass bean
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950

Don't treat your View Definitions -and the EL - like they're some sort of programming language. That's not how it works.

In other words, don't code action method references like they were function calls:

Similarly, on property references:

Customer surveys are for companies who didn't pay proper attention to begin with.
Jason A Wong

Joined: Dec 10, 2012
Posts: 4
Fixed it in code, doesn't solve anything though I think.
I've been looking online a lot, and most of the stuff that relates to keeping values in session across different JSF pages includes editing the faces-config.xml file.
Using NetBeans, faces-config.xml is supposedly not needed. So I was wondering if it was possible to create that xml file and just input what I needed into it.
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1076

Hi Jason,
Welcome to the Ranch!

Your issue is not completely clear to me. You have said that the value is getting displayed in page 2, which means the session is working fine. Where do you get the problem?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950

IDEs have nothing to do with this.

In JSF Version 1, the scope and initialization of JSF Managed Beans was defined in the faces-config.xml file. In JSF2, the option was added to define scope and initialization as Java annotations in the bean's class definition. If a conflicting bean declaration is found in faces-config.xml, that declaration will override the annotations, thereby making it easier to re-use code without editing and recompiling it. There are also some other things that are not possible to declare with code annotations, such as integration of the Spring Framework into the JSF EL context, so faces-config.xml isn't completely useless, even these days. Although if you don't use any of those features, you may omit that file entirely.

To get values from one View to another, the 2 Views (pages) need to be able to reference a common backing bean. This bean has to be Session Scoped or higher. Request Scoped beans are destroyed each time they're used, and View Scoped beans don't survive the transition from one View to the next. I'm ignoring Flash scope here, since that's better left until you have the basic concepts working for you.
Jason A Wong

Joined: Dec 10, 2012
Posts: 4
Found out what I needed to do, though it's not pretty looking.
Made beans SessionScoped, and passed parameters through JSF. Pretty sure there's an easier way. But it's a start.
I agree. Here's the link: http://aspose.com/file-tools
subject: Another parameter passing noob
Similar Threads
Injection problem - not quite sure if this is something i should be using injection for
Managed bean is immediately called on page load
viewScoped bean recreated on page reload
Trying to change <ui:include> src tag dinamically