Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter passing between request scope beans

 
Pho Nghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone point me in the right direction in passing parameters through request scoped beans? I can't find any examples. I'm using version 1.2 I can do it perfectly fine with a session scope but not getting it on a request scope.
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pho Nghi,

Could you please be more specific of what you need and where you stuck?
 
Yosi Pramajaya
Ranch Hand
Posts: 46
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you still using JSF 1.2.1...
2.0 is better, isn't it?

Maybe you can set a value in your second request-scoped bean by the first request-scoped bean.
For example:
(I don't know if this can be work or not, this just a tips)



Or, you can just use @ApplicationScope or @SessionScope
Because, I use @RequestScope very very rarely.

Hope could helping.
 
Pho Nghi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using 1.2 because I was forced too

What I am doing is using rich faces to upload a document. So I have upload.jsp, uploadbean.java, uploadform.jsp, and uploadformbean.java
The upload.jsp will use rich faces to upload a document and grab some of it's properties and store them in the uploadbean.java. Once it is done uploading it will go to the next page uploadform.jsp and display some of the properties of that document which I was hoping to pass the parameters from uploadbean.java to uploadformbean.java. I wanted to keep this all request scope so I can learn on how to do it.

Is this much clearer?
 
Yosi Pramajaya
Ranch Hand
Posts: 46
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hohoho.. It's surprising me because I thought that we as a developer / programmer must not forcing anyone..

Anyway, I've no experience in creating web projects directly (go through server, upload and etc). But I still recommend the same things as before, maybe you should try it too.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request scope doesn't work very well in JSF. Request scope objects have a lifecycle limited to a single request/response, and JSF often makes multiple requests per page. And in no case can you use request scope to define beans for pages yet undisplayed.

Beyond that, "parameter passing" isn't how JSF was designed to work. JSF is about Inversion of Control, and in IoC, you don't use a bunch of framework-specific APIs to get data passed around, you define bean wiring to the JSF framework, which then injects source beans into target beans, allowing them to trade info using POJO set/get methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic