Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another parameter passing noob

 
Jason A Wong
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Jason A Wong
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic