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

  • Home
  • SEARCH
  • 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 7405941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:28:49+00:00 2026-05-29T05:28:49+00:00

I’m having an issue with a form that I have. The form allows users

  • 0

I’m having an issue with a form that I have. The form allows users to enter info into some textboxes and then there are 2 buttons – Search and Reset.

Form code:

<h:outputText value="Search by Author Name" styleClass="p" />

<div class="investigatorTab">

    <h:outputLabel for="firstName" rendered="true" value="First Name" />
    <h:inputText value="#{pubBacker.firstName}"></h:inputText>

    <h:outputLabel for="lastName" rendered="true" value="Last Name" />
    <h:inputText value="#{pubBacker.lastName}"></h:inputText>

</div>

<div class="buttons">
    <p:commandButton value="Submit" styleClass="submitButton" action="#{pubBacker.submit}" update="tabs" />
    <p:commandButton value="Reset" type="button" actionListener="#{pubBacker.clearEntries}" onclick="clearForm(this.form);" />
</div>

The problem I’m having is that if I click the search button, it takes me to the results page and if I go back to the search page, it still has the data that I searched with in the text fields because the bean is session scoped. I want to be able to click the Reset button and have the data in the text fields clear.

Currently with the code below, if I click the Reset button, The search button no longer works and in the firebug console it gives me this error

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><error><error-name>class javax.faces.application.ViewExpiredException</error-name><error-message><![CDATA[viewId:/ccadmin/pubManagement.xhtml - View /ccadmin/pubManagement.xhtml could not be restored.]]></error-message></error></partial-response>

If I remove the onclick="clearForm(this.form);" from the second p:commandButton, the form works fine.

Any ideas why calling a JS function would make the view expire?

Publication Bean:

@ManagedBean(name="pubBacker")
@SessionScoped
public class Publication {

    public Publication() {}

    public void clearEntries() {
        new Publication();
    }
}
  • 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-29T05:28:49+00:00Added an answer on May 29, 2026 at 5:28 am

    You’re apparently clearing all elements of the form by blindly looping through form.elements. This way the javax.faces.ViewState hidden input field which is auto-included by JSF will be cleared as well and hence JSF will retrieve an empty value and it won’t be able to find the associated view state in the server side. This will ultimately end up in a ViewExpiredException.

    I suggest to just not use JS to clear the form, but only JSF. It’s easier if you have a model which represents the form.

    <div class="investigatorTab">
        <h:outputLabel for="firstName" rendered="true" value="First Name" />
        <h:inputText value="#{pubBacker.pub.firstName}"></h:inputText>
    
        <h:outputLabel for="lastName" rendered="true" value="Last Name" />
        <h:inputText value="#{pubBacker.pub.lastName}"></h:inputText>
    </div>
    
    <div class="buttons">
        <p:commandButton value="Submit" styleClass="submitButton" action="#{pubBacker.submit}" update="tabs" />
        <p:commandButton value="Reset" action="#{pubBacker.clear}" process="@this" update="@form" />
    </div>
    

    (note the process="@this", this won’t process the form’s input values and thus not validate them)

    with

    public void clear() {
        pub = new Pub();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.