• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

variable to initialize not working?

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just newbie in JSF and I was stuck in this code for the whole day.

I've got a simple JSP program where you can put on a textfield and guess the generated random number, it has a link where you can reload (to generate new random number and initialize the i variable as number of attemps made) . When I use the navigational case xml in faces-config.xml and use the class in CODE A, the program is working fine.

But when I modified the the class and make another class as listener the i variable and generatedNumber is not initializing anymore. I almost ran out of solution. Please help.

the jsp program simply runs like this.

in start of prgram, the class will generated a random number (0-9).
Then I will put my number to guess.
If not correct i variable will increment by one (this is the number of attempts made)

In case I click the 'Reload' link, there should be another random number and i variable shld go to 0 again.


The problem:
When I click 'Reload' link its not doing another random number, and i variable never return to 0
instead
the old random number shows and i variable continues to increment.


Other story:
The CODE A, this is working fine. When I click' Reload' in my JSP, its generated new number and variable i initializes again.

Then I changed it as listener, then the problem (I stated above) occurs.


I hope my story is clear, I really stuck in this problem, thanks and appreciate your help. If you need more clearer explanation please just tell me to elaborate more.




CODE A









CODE B

 
reply
    Bookmark Topic Watch Topic
  • New Topic