Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6860213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:22:50+00:00 2026-05-27T02:22:50+00:00

CASE: the form contains input text for entering department name (can’t be null or

  • 0

CASE: the form contains input text for entering department name (can’t be null or blank), and drop down list for selecting parent department (can be null), when entering data, and pressing clear, the clear method in backing bean works fine as expected, but when not entering data and pressing clear, the bean validation for not blank on the name works and validation message appears, and i want to disable the validation in case of clearing.

  1. View Code:

    Department Name:

    <h:outputLabel>Parent Department:</h:outputLabel>
        <ice:selectOneMenu id="parentDepartment" value="#{department.selectedParentDepartment}">               
          <f:selectItem/>
          <f:selectItems value="#{departmentBean.departmentList}" var="dept" 
           itemLabel="#{dept.name}" itemValue="#{dept.id}" />                            
        </ice:selectOneMenu> 
        <h:message for="parentDepartment" style="color:red" />        
    
    <ice:panelGroup>
        <h:commandLink value="Add New" action="#{departmentBean.addOrUpdateDepartment}" />
        <h:commandLink value="Add New" actionListener="#{departmentBean.clear}" />
    </ice:panelGroup>
    

  2. Bean Validation:

    @NotBlank(message = "{name.required}")
    @Size(max = 25, message = "{long.value}")
    @Column(name = "name", length = 25, nullable = false)
    private String name;

  3. Backing Bean Method:

    public void clear() {
    setDepartmentObj(new Department());
    setSelectedParentDepartment(0);
    }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:22:50+00:00Added an answer on May 27, 2026 at 2:22 am

    You can let it refresh the entire view instead:

    <h:commandLink value="Clear" action="#{bean.clear}" immediate="true" />
    

    with

    public String clear() {
        return FacesContext.getCurrentInstance().getViewRoot().getViewId() + "?faces-redirect=true";
    }
    

    The immediate="true" will skip processing (and validation) of all input components which doesn’t have immediate="true".

    Alternatively, a piece of JavaScript to reload the page should also do:

    <h:commandLink value="Clear" onclick="window.location.reload(); return false;" />
    

    Update as per the comments you want a partial request, then just use ajax:

    <h:commandLink value="Clear" action="#{bean.clear}">
        <f:ajax execute="@this" render="@form" />
    </h:commandLink>
    

    with

    public void clear() {
        field1 = null;
        field2 = null;
        // ...
    }
    

    Because the execute is set to @this (which is already the default value by the way, so you can omit it), it won’t process the entire form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am entering data in the text field of my form that contains 2
I have a page, it has a drop down list, which contains the names
I have a form that has three submit buttons as follows: <input type=submit name=COMMAND
I need to send information input into a text box in one form to
Page contains single form with input elements and jqgrid data. jqGrid data is retrieved
I have an input form with a column on the left that contains the
A date selection HTML form section contains two drop downs - one for the
I have a ASP.Net web form that contains both text box fields and hidden
I have a form where users can subscribe and unsubcribe to my email list.
I have a case where i want to submit a form and get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.