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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:53:58+00:00 2026-05-21T19:53:58+00:00

what I have is jsf page that shows users in a table, one of

  • 0

what I have is jsf page that shows users in a table, one of the columns is commandbutton, that hides that table and shows another table with all articles that that user has.Here things are OK. The articles table again has column with commandbuttons that has to hide that table and show the article content, but it shows the user table. In my bean I have 3 properties

    private Boolean usersViewActive;
    private Boolean articlesViewActive;
    private Boolean articleContentViweActive;

and methods that activate one of them and deactivate the others

    public void activateUsersView() {
        this.usersViewActive = true;
        this.articlesViewActive = false;
        this.articleContentViweActive=false;
    }

    public void activateArticleView() {
        this.usersViewActive = false;
        this.articlesViewActive = true;
        this.articleContentViweActive = false;
    }

    public void activateArticleContentView() {
        this.articleContentViweActive = true;
        this.usersViewActive = false;
        this.articlesViewActive = false;
    }

My bean

@ManagedBean
@RequestScoped
public class DataBean {
    private List<UserAcc> users;
    private List<Article> articles;
    private List<ArticleComment> articleComments;

    private Article currentArticle;

    private Boolean usersViewActive;
    private Boolean articlesViewActive;
    private Boolean articleContentViweActive;

    public DataBean() {
        DataBaseUtil dbu = new DataBaseUtil();
        users = dbu.loadUsers();
        this.usersViewActive = true;
    }

    public void activateUsersView() {
        this.usersViewActive = true;
        this.articlesViewActive = false;
        this.articleContentViweActive=false;
    }

    public void activateArticleView() {
        this.usersViewActive = false;
        this.articlesViewActive = true;
        this.articleContentViweActive = false;
    }

    public void activateArticleContentView() {
        this.articleContentViweActive = true;
        this.usersViewActive = false;
        this.articlesViewActive = false;
    }

    public void loadArticles(ActionEvent e) {
        DataBaseUtil dbu = new DataBaseUtil();
        int userId = (Integer) e.getComponent().getAttributes().get("userId");
        articles = dbu.loadUserArticles(userId);
    }

    public void loadComments(ActionEvent e) {
        DataBaseUtil dbu = new DataBaseUtil();
        int articleId = (Integer) e.getComponent().getAttributes()
                .get("articleId");
        articleComments = dbu.loadArticleComments(articleId);
    }

    public void loadCurrentArticle(ActionEvent e) {
        DataBaseUtil dbu = new DataBaseUtil();
        int articleId = (Integer) e.getComponent().getAttributes()
                .get("articleId");
        this.currentArticle = dbu.loadArticleById(articleId);
    }

  Getters and Setters...
}

My Page:

<h:body>
    <h:panelGroup rendered="#{loginBean.authorised}">
        User: <h:outputText value="#{loginBean.name}"></h:outputText>
        <a href="new_article.jsf">Add article</a>
    </h:panelGroup>
    <h:panelGroup rendered="#{not loginBean.authorised}">
        <h:outputText>You are not authorised to be here!</h:outputText>
        <a href="index.jsf">Login or Registrate</a>
    </h:panelGroup>

    <h:form>
        <h:panelGroup rendered="#{loginBean.authorised}">

            <!--                    All users -->
            <h:panelGroup rendered="#{dataBean.usersViewActive}">
                <rich:dataTable value="#{dataBean.users}" var="user" rows="10">
                    <f:facet name="header">Users</f:facet>
                    <rich:column>
                        <f:facet name="header">User Id</f:facet>
                        <h:outputText value="#{user.id}"></h:outputText>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">User Name</f:facet>
                        <h:outputText value="#{user.name}"></h:outputText>
                    </rich:column>
                    <rich:column>
                        <h:commandButton value="Show articles"
                            action="#{dataBean.activateArticleView}"
                            actionListener="#{dataBean.loadArticles}">
                            <f:attribute name="userId" value="#{user.id}"></f:attribute>
                        </h:commandButton>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:dataScroller></rich:dataScroller>
                    </f:facet>
                </rich:dataTable>
            </h:panelGroup>

            <!--                    All articles -->
            <h:panelGroup rendered="#{dataBean.articlesViewActive}">
                <h:commandButton value="Back to users"
                    action="#{dataBean.activateUsersView}"></h:commandButton> 
                <rich:dataTable value="#{dataBean.articles}" var="article" rows="10">
                    <f:facet name="header">Articles</f:facet>
                    <rich:column>
                        <f:facet name="header">Article Id</f:facet>
                        <h:outputText value="#{article.id}"></h:outputText>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Article Title</f:facet>
                        <h:outputText value="#{article.title}"></h:outputText>
                    </rich:column>
                    <rich:column>
                    <!-- Here is the problem  -->
                    <!-- This button renders all users instead article content -->
                        <h:commandButton value="Show article content and comments" 
                        action="#{dataBean.activateArticleContentView}"
                        actionListener="#{dataBean.loadCurrentArticle}">
                            <f:attribute name="articleId" value="#{article.id}"></f:attribute>
                        </h:commandButton>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:dataScroller></rich:dataScroller>
                    </f:facet>
                </rich:dataTable>
            </h:panelGroup>

                <!-- Article content -->
            <h:panelGroup rendered="#{dataBean.articleContentViweActive}">
                <h:outputText value="#{dataBean.currentArticle.title}"></h:outputText>
                <h:outputText value="#{dataBean.currentArticle.text}"></h:outputText>
            </h:panelGroup>
        </h:panelGroup>
    </h:form>

</h:body>
  • 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-21T19:53:59+00:00Added an answer on May 21, 2026 at 7:53 pm

    Your bean is request scoped and you aren’t maintaining/preserving the value behind rendered attribute for the subsequent request. All those values defaults to false when a fresh new request scoped bean is constructed upon form submit. The commandbutton’s action won’t be invoked when the rendered attribute evaluates false during the form submit. JSF will namely test it once again before processing the form submit.

    Put the bean in the view scope.

    @ManagedBean
    @ViewScoped
    public class DataBean implements Serializable {
        // ...
    }
    

    This way the bean lives as long as you’re interacting with the same view by returning void or null in action methods.

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

Sidebar

Related Questions

In my JSF 1.2 webapp I have a page with a <h:commandButton> that invokes
I have a page that lists all from my Post table, it looks like
I have a JSF page that displays a RichFaces Treeview, from a TreeNodeImpl model
I have two JSF <h:selectOneMenu> components. One called category another is subcategory . If
I have a commandButton in JSF 2.0 with a actionvalue that I want to
I have a table where one of it's columns contains a dropdown list (HtmlSelectItems
I have a JSF page that is basically a create form. The form consists
I have a PrimeFaces checkbox on a JSF page that I'd like to check/uncheck
i have an object that holds an imageIcon, in a jsf page this line
Ok simple question. I have a JSF application, containing a login page. The problem

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.