• 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

keep the values of my input text fields

 
Ranch Hand
Posts: 36
3
Eclipse IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I have a input text that I want to activate only when I check a checkbox, the problem is that every time that I check or uncheck the checkbox, all the data that I have in my other input text disappears.

This is the secction of my code that generate the textfield and the checkbox and some buttons. What I am doing wrong?? Is there anyway to keep the data that is in my input text, (maybe using javascript or any option)?

Note: the code that defines my page, is inside in only one <form>

<BR />
<h:outputLabel for="jobname" value="Would you like to assign a specific job name?" />

<h:selectBooleanCheckbox
id="jobname"
title="Job Name"
immediate="true"
valueChangeListener="#{reportRunner.checkNameChange}"
style="position:relative;left:10px;"
disabled="displayJobName()"
value="#{reportRunner.wantsName}"
onchange="this.form.submit()"
onclick="displayJobName()" >
</h:selectBooleanCheckbox>

<BR />
<h:inputText
id="userjobname"
value="#{reportRunner.userJobName}"
rendered="#{reportRunner.needName}"
style="display:none"
required="#{reportRunner.needName}"
valueChangeListener="#{reportRunner.userJobNameChanged}"/>
<h:message for="userjobname" styleClass="errorMessage"/>

<BR />
<BR />
<h:message for="run_report" styleClass="errorMessage"/>
<BR />
<h:commandButton type="button" class="button" disabled="true"
value="Previous"
action="#{reportRunner.previous()}"
/>
<h:commandButton type="submit" class="button"
value="Next Page"

action="#{reportRunner.nextPage()}"
/>

<h:commandButton class="button"
immediate="true"
value="#{messages['command.cancel']}"
action="#{reportRunner.goBack()}"
/>
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your backing bean is Request scope, that's your problem. Use View Scope (JSF2) or session scope (JSF1+).
 
Fernando Guerrero
Ranch Hand
Posts: 36
3
Eclipse IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My scope was "session", I already changed it to "view" but I have the same problem. Is there any way to save the values of the inputText fields with javaScript and after I check the checkbox and all the fields are blank, write back those values into the fields? Do you require that I post the full page code?

Thanks
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If reportRunner is in View scope or higher, the input fields should retain their value without requiring you to do anything at all. When a JSF page is displayed, the current values of the properties will be displayed automatically. That's Request Scope doesn't work - a whole new bean would have been created with whatever values the bean had initialized to.

You seem to be overcomplicating this operation. If you want an AJAX-style auto-submit of a value on enter, you don't need valuechangelisteners, since the normal JSF lifecycle is going to set the property for you. However, I have doubts about using raw JavaScript to submit the JSF form. You're better off using an AJAX-aware tagset such as RichFaces or IceFaces or use the JSF2 AJAX features.
reply
    Bookmark Topic Watch Topic
  • New Topic