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 6058821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:38:30+00:00 2026-05-23T08:38:30+00:00

I’m learning Java EE 6 and JSF 2.0 on JBoss6 and have built a

  • 0

I’m learning Java EE 6 and JSF 2.0 on JBoss6 and have built a very simple 1 page “Todo” app which works but with a very strange bug. Tested in Safari 5.0.5 and Firefox 5.

There are two actions you can do (add a todo and check/uncheck todos). It all works, but not the first time an action is done after a different action has been done.

And example usage might look like this:

  1. try to add a todo = success
  2. try to add a todo = success
  3. try to check a todo = fail
  4. try to check a todo = success
  5. try to add a todo = fail
  6. try to add a todo = success
  7. try to check a todo = fail

The app has the following basic files (plus other bits and pieces):

  • entities/Todo.java <- JPA entity
  • managers/TodoManager.java <- EJB for handing the Todo entities, @Stateless
  • controllers/TodoController.java <- managed bean for the page, @SessionScoped
  • todos.xhtml <- the JSF page

No faces-config.xml

The form to add a todo looks like this:

<h:panelGroup id="projects">
   <h:message for="newtitle" />
   <h:form id="newtodo">
    <h:panelGrid columns="5">
            <h:outputText value="New Todo: "/>
            <h:inputText id="newtitle" value="#{todoController.todo.title}" />
            <h:outputText value="Due: "/>
            <h:inputText id="newDueDate" value="#{todoController.todo.dueDate}">
                <f:convertDateTime pattern="dd/mm/yyyy"/>
            </h:inputText>
            <h:commandButton action="#{todoController.addTodo}" value="add">
                <f:ajax execute="@form" render=":projects"/>
            </h:commandButton>

the form to check/uncheck the todo “done” status looks like this:

<h:form>
    <h:dataTable id="todolist" var="t" value="#{todoController.todolist}">
        <h:column>
            <h:selectBooleanCheckbox id="rowCheckbox" value="#{t.done}" >
                <f:ajax event="click" listener="#{todoController.updateDone(t)}" render=":projects"/>
            </h:selectBooleanCheckbox>
        </h:column>

TodoController looks like this:

@ManagedBean(name="todoController")
@SessionScoped
public class TodoController 
{
    @EJB
    private TodoManager todoManager;
    private Todo todo = new Todo();
    private ArrayList<Todo> todolist = new ArrayList<Todo>();

    public String addTodo()
    {
        todo.setDone(false);
        todo.setUser(this.getLoggedInUser());
        todoManager.addTodo(todo);
        todo = null;
        return "todos.xhtml";
    }

    public String updateDone(Todo t)
    {
        t.setDone(!t.getDone());
        todoManager.updateTodo(t);
        return "todos.xhtml";
    }

I did add logging messages to addTodo() and updateDone(Todo t) to verify when they get called. When the actions are “not working” they in fact don’t seem to get called at all. 🙁

  • 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-23T08:38:32+00:00Added an answer on May 23, 2026 at 8:38 am

    This will happen when you have 2 forms of which second form is re-rendered by sumbitting the first form. This way the JSF view state of the second form will be completely lost (you can determine it yourself by the absence of a hidden input field with the name javax.faces.ViewState in the Ajax response). Submitting the second form after being re-rendered by a submit of the first form would then visually have no effect. Without the view state JSF won’t process the submit of the form. Only a new form (with the proper view state!) will come back in place and hence the second submit works.

    You need to finetune the render attribute that way that only the contents of the second form is re-rendered and not the whole form itself.

    E.g.

    <h:form id="form1">
        <h:panelGroup id="content">
            ...
            <h:commandButton value="Submit">
                <f:ajax execute="@form" render="@form :form2:content" />
            </h:commandButton>
        </h:panelGroup>
    </h:form>
    <h:form id="form2">
        <h:panelGroup id="content">
            ...
            <h:commandButton value="Submit">
                <f:ajax execute="@form" render="@form :form1:content" />
            </h:commandButton>
        </h:panelGroup>
    </h:form>
    

    In your particular case, give the <h:panelGrid> of the first form and the <h:dataTable> of the second form a fixed id and re-render just that from the other form on.

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

Sidebar

Related Questions

No related questions found

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.