How to reset an error from view or backing bean?

The JSF view shown below sets attributes 'required' and 'disabled' of an
h:inputText depending on the input value on a h:selectBooleanCheckbox.
It mostly works but a serious problem is that when the user enables the
h:inputText and pushes the submit button with blank input, message
"Validation Error: Value is required." is displayed. The error message
is quite natural but the core of the problem is that at this state,
changing the checkbox value to false(==unchecked) doesn't cause the
reset of error and disabling/non-requiring of the textfield. Checkbox
becomes unchecked by user mouse operation but textfield remains enabled.
How could I have the textfield disabled and non-required when the user
did some non-standard(?) operation described above?
[VIEW]
<f:view>
<h:form id="mform">
<h:selectBooleanCheckbox id="mflag" immediate="true"
                         value="#{mailBean.mailFlag}"
                         onchange="this.form.submit();" >
<h:outputText value="I'll send my mail address" />
</h:selectBooleanCheckbox>
<br>
<h:outputLabel for="mailtext" value="mlabel">
Enter Your Mail Address:</h:outputLabel>
<h:inputText id="mailtext"
             required="#{mailBean.mailFlag}"
             immediate="#{! mailBean.mailFlag}"
             disabled="#{! mailBean.mailFlag}"
             value="#{mailBean.mailText}"/>
<h:message for="mailtext"/>
<br>
<h:commandButton id="msubmit" value="submit" action="success"/>
</h:form>
</f:view>
[BEAN]...scope of the managed bean mailBean is session...
public class MailBean{
  private boolean mailFlag = false;
  private String mailText;
  public void setMailFlag(boolean flag) {
    mailFlag = flag;
    if (! flag){
      mailText = "";
  public void setMailText(String str) {
    mailText = str;
  public boolean getMailFlag() {
    return mailFlag;
  public String getMailText() {
    if (! mailFlag) {mailText = "";}
    return mailText;
}

The JSF view shown below sets attributes 'required'
and 'disabled' of an
h:inputText depending on the input value on a
h:selectBooleanCheckbox.
It mostly works but a serious problem is that when
the user enables the
h:inputText and pushes the submit button with blank
input, message
"Validation Error: Value is required." is displayed.
The error message
is quite natural but the core of the problem is that
at this state,
changing the checkbox value to false(==unchecked)
doesn't cause the
reset of error and disabling/non-requiring of the
textfield. Checkbox
becomes unchecked by user mouse operation but
textfield remains enabled.Have you tried setting the immediate property to true for the checkbox, and not using it for the inputText component? It looks to me like that's the one you want to run first, before validation is performed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann ([email protected])
Principal Consultant, Virtua, Inc. (http://www.virtua.com)
Author, JavaServer Faces in Action
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
Are you using JSF in a project? Send your story to [email protected], and you could get your story published and win a free copy of JavaServer Faces in Action

Similar Messages

  • How to solve this error from window phone 80073cf9 lumia 630.

    any one know how to solve this error from window phone 80073cf9  lumia 630.

    Hello Muhammad,
    We appreciate the post, but this forum is for Windows Store and Phone Developer related questions. Your question can best be answered through the
    Windows Phone support page.
    Thanks!
    -Jonathan
    Windows Store Developer Support
    Office Store Developer Support

  • How do you delete file from time machine back up?

    How do you delete file from time machine back up?

    This from Apple KB Article  If Time Machine is not in your Dock, you can enter Time Machine from the Menu Bar or System Preferences.
    Deleting data from a Time Machine backup
    To delete all backups of one or more items from a Time Machine backup, follow these steps:
    Click the Time Machine icon on your Dock to enter the Time Machine restore interface.
    Click on the item you would like to delete. Command-click to select multiple items.
    Control-click (or right click) the highlighted item(s) and select "Delete All Backups of..." from the contextual menu, or select "Delete all backups of..." from the Action Item menu.
    Authenticate with an administrator password when prompted.

  • I had to restore my computer to the factory settings, which means my itunes library was lost except for what was on my ipod nano.  How do pull the songs from my ipod back onto my computer?

    I had to restore my computer to the factory settings, which means my itunes library was lost except for what was on my ipod nano.  How do pull the songs from my ipod back onto my computer?  I have over 200 songs.  There is no way I can re-purchase them!  Any help?

    How to use your iPod to move your music to a new computer 

  • I have limited space left on my iphone.  How do I send music from my iPhone back to the cloud so it doesn't take up all my space, if I decide I want different music?

    I have limited space left on my iphone.  How do I send music from my iPhone back to the cloud so it doesn't take up all the space on my phone, if I decide I want different music?

    You don't send it back to the cloud since it never left the cloud.
    You can delete indovidual songs from the iPod, or if all music is available in your iTunes library on your computer, you can remove the music from your iPhone via the iTunes sync process.

  • How do I transfer Contacts from my IPhone5 back to my computer (windows)?  It crashed and I lost my contacts but I have them on my IPhone5 and would like to transfer or export them.

    How may I transfer Contacts from my IPhone5 back to my Windows Computer.  I had a trojan virus and it wiped out everything including my contacts.  My IPhone 5 has the only complete list of my contacts and I'd like to have them back on my computer.

    Hi Jean167,
    I'm sorry to hear you of your issues with contacts being erased from your computer.
    You can copy them from the iPhone if you have iCloud setup on all your devices.
    Here are some articles / information that may help:
    Creating an iCloud account: Frequently Asked Questions
    iCloud: System requirements
    PC
    Microsoft Windows 7 or 8
    iCloud Control Panel 2.1.2 or later
    iTunes 11 or later (for iTunes in the Cloud and iTunes Match)
    Outlook 2007 or 2010 or iCloud.com
    Safari 5.1.7 or later or Internet Explorer 9 or later (for iCloud.com and Bookmarks), Firefox 16 or later or Chrome 23 or later (for iCloud.com)
    iCloud Control Panel 2.1.2 for Windows
    I hope this information helps, Jean ...
    - Judy

  • After updating to IOS 8.2 my iphone 5 constantly searches for a network. I have tried resetting network, restoring from an earlier back up, resetting as a new phone - all of which have been unsuccessful- HELP !!

    After updating to IOS 8.2 my iphone 5 constantly searches for a network. I have tried resetting network, restoring from an earlier back up, resetting as a new phone - all of which have been unsuccessful… HELP !!

    Hi chuckrabaw,
    Thanks for using Apple Support Communities. Based on what you stated, it sounds like the iPhone is searchiong for a network. It looks like you have already done some troubleshooting. There are a few steps listed in this article you did not mention trying, they may be able to help the issue.
    If you see No Service in the status bar of your iPhone or iPad - Apple Support
    Cheers,
    Mario

  • HT4623 i cant work out how to transfer my stuff from i-tunes back onto my phone? any help would be much appriciated

    i cant work out how to transfer my stuff from i-tunes back onto my phone? any help would be much appriciated

    do you mean how to restore a backup
    https://discussions.apple.com/thread/3053632
    or do you mean how to sync media and apps to itunes
    http://www.apple.com/support/iphone/syncing/

  • HT201210 how can i retrieve texts from an earlier back up without changing all the other settings on my iphone?

    how can i retrieve texts from an earlier back up without changing all the other settings on my iphone?

    You can't. Restoring from a backup is all or none.
    You can use a utility such as this one to extract the messages from the backup on your computer but you can't re-transfer the messages to the Messages app on your iPhone.
    http://msb.macsupport-pr.com/

  • HT4859 How do I get everything from my icloud back on to my ipad if I accidentally erased it?

    Please help!!! How do I get everything from my icloud back on to my ipad if I accidentally erased it?

    I Have the same problem but I don't know srry

  • How do you download photos from the icloud back to your phone?

    How do you download photos from the icloud back to your phone? I want to save my photos on my hard drive and not in the cloud.

    iPhoto 9.2 (and higher) can move your Photo Stream files and store them permanately on your computer and move them to your phone.
    You can also move them on your iPhone from Photo Stream to Camera Roll.

  • How to find lost files from Iphone without back up

    How to find lost files from iPhone without back up?

    If you don't have a back up, there's no where to restore them from.

  • How do I put content from my iphone back into itunes after installing a new hard drive?

    How do I put content from my iphone back into itunes after I have installed a new hard drive on my computer?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • How to refresh the input text value in backing bean

    hi all
    i want to know
    how to refresh the input text value in backing bean?
    i have tried this code ,but it doesnt work
    public void click(ActionEvent actionEvent) {
    tempConId.setValue("111111111111111");
    AdfFacesContext.getCurrentInstance().addPartialTarget(tempConId);
    sb know?
    Edited by: Joe Zou on 2012-4-6 下午9:11

    The code looks good.
    Here is a sample based on your use-case:
    InputTextSample.jspx:
    <af:form id="f1">
            <af:panelFormLayout id="pfl1">
              <f:facet name="footer">
                <af:commandButton text="Ok" id="cb1" partialSubmit="true"
                                  actionListener="#{InputTextSampleBean.onClick}"/>
              </f:facet>
              <af:inputText label="InputText" id="it1"
                            binding="#{InputTextSampleBean.myInputText}"/>
            </af:panelFormLayout>
          </af:form>
    InputTextSampleBean.java:
    import javax.faces.event.ActionEvent;
    import oracle.adf.view.rich.component.rich.input.RichInputText;
    import oracle.adf.view.rich.context.AdfFacesContext;
    public class InputTextSampleBean {
        private RichInputText myInputText;
        public InputTextSampleBean() {
        public void setMyInputText(RichInputText myInputText) {
            this.myInputText = myInputText;
        public RichInputText getMyInputText() {
            return myInputText;
        public void onClick(ActionEvent actionEvent) {
            this.myInputText.setValue("1234");
            AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
            adfFacesContext.addPartialTarget(this.myInputText);
    }

  • How to get the current JSF phase in backing bean?

    How to get the current JSF phase in backing bean?
    Edited by: jimmy6 on Nov 27, 2007 7:27 AM

    I am using phasetracker to trace it also.I want to know whether it is it render response phase. I know FacesContext.getCurrentInstance().getRenderResponse() work for normal jsf component but it will not work for qiupukit datatable. FacesContext.getCurrentInstance().getRenderResponse() will not return true in the following phase. Why?
    [ INFO] 27-11-07 16:20:21 : BEFORE RENDER_RESPONSE(6) (http-80-Processor23)
    I want the 'get' method of datatable being called in response phase to reduce the number of calling because i put the query in 'get' method there. Actually i still straggling with the best practice to code the datatable...

Maybe you are looking for