Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jason Delboch

Greenhorn
+ Follow
since Apr 01, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jason Delboch

Tim,

Basically what im trying to say is...

Page1 - the from page - RequestScope

Page2 - the page im populating with data and main concern - SessionScope

So the flow is , i enter a serial num on page1 and a table with rows pops up displaying records dealing with that serial.
I then click on the table row i want to goto, in turn im brought to page2 with all the data displayed in the respective inputbox.

So let me describe more clearly what my situation is:
When i populate page2, I'm doin a select on a db table to do so. I have this done inside a getter on the page. In order for this to only happen once I use a boolean to check if its false do the db stuff and then set to true so it wont go through again. Because theres going to be 20-40 people running the application at the sametime and that would be bad news if it happened more than once. Since this page is sessionScope after the initial call, the constructor is never called again and like wise with the pageScope variables. A boolean wont be reset to false if I come back to this page. I can't always guarunte the user will click the given buttons on the page i can use to reset the bool back to false. They may click on the template links and leave the page that way, in which i need to deal with that also. I was propsing that I make the boolean i need to reset in Page1 and inject it in page2 (which you just said i can't). Can i possibly then, in the constructor for page1 have the boolean initialized there, create a Page1 object in Page2 and then call a getter on the object to get the boolean? I'm trying to get this to work anyway I can simply because I'm put inside this box of having to use jsf,not being able to change the scope or installing prettyfaces(which sounds cool to try) - really I'm stuck using what I've got to do it. I've tried onunload and an array of other stuff, but no luck. The only issue with doing what I proposed is im not exactly sure on the lifetime of the object of type page1. Lemme know if that cleared up things alittle more.

thnx,
Jason
13 years ago
JSF
Tim,

Thats a super useful example, most appreciated. That will totally help me when the user goes from the 'from' page. Now I'm still stuck on how to deal with this boolean when users leave the page via template links. If i turn the 'from' page into requestScope and declare the boolean there, then in turn make an instance of that object in the main page im dealing with. Wouldn't that fix my issue because everytime I made the object the boolean would be false, because the page would be requestScope right?

13 years ago
JSF
So i was just informed we have jsf 1.0 , which means i can't use annotations. The prepareForDisplay method makes sense, although i can't honestly say i totally understand injection. So would I basically just create a new object in the 'from' page? Also if I make two objects from the same backerbean, which one will I actually be going to? Confused on some stuff, been reading , but alot of info.
13 years ago
JSF
Tim,

It's not an option for me to change the page to request scope, it must stay in session scope(this is not up to me). Which is making me think im in a heap of trouble with my original problem. How can i reset this variable when i come back to the page everytime? The page is in sessionScope, which i believe is why my declarations and constructor are only called on the original call to the page. I'm looking into the jsf tagsets you were talking about related to hidden fields and the annotation.

thnx,
Jason
13 years ago
JSF
My codes blowing up here:

String getDIS_Serial() {
**null**> if(getRequestScope().get("populatePage")==null){
System.out.println("setter");
getRequestScope().put("populatePage","false");
}
return DIS_Serial
}

So if I put the value in a hidden field, how would that stop this null from happening?
13 years ago
JSF
Tim,

Appreciate the response and I wasn't fully aware of the leaving page illusion. I've tried to use RequestScope Variables, but found everytime past the first time i used the page, i'd always get nulls. I was resetting the RequestScope Variable everytime it entered the page in one of the getters for a faces component. So I was really unsure of as to why i was getting nulls when in my mind i was sure i was setting it. I was doing what i thought was correct in getRequestScope.put(code) and a few lines later when i tried to use the same variable it'd throw a null.

j
13 years ago
JSF
The nav links are on a template that i can't change. The only thing i can actually edit is this individual page. I've been trying to add an onunload to the page and I'm having issues with that.

13 years ago
JSF
Was under the impression this was a jsp matter... anyway sry, still need help
13 years ago
JSF
Hello,

Im very new to JSP/JSF and need some guidance on how to set a boolean in my backer bean to be false. The general situation that I'm in now is , I get some information from the database and populate the page all in a getter on the page. It seems that the getter for values on a jsp are called numerous times . I obviously don't want this to happen multiple times and so i set a boolean to true after the first time it happens. If the user decided to click on a nav link instead of pressing the button on the page, I need to change this boolean back to false. I looked into onunload, but didn't get very far with it. Am I heading in the right direction?

ty
13 years ago
JSF