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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:42:17+00:00 2026-05-21T12:42:17+00:00

I use a primefaces dock as a nav bar. I want it to change

  • 0

I use a primefaces dock as a nav bar. I want it to change one of its images depending on if the user is logged in or not. I did something but it doesn’t work, because i see the two icons at the same time and also i cant click the logout button. Can you give me some advice?

This is the nav bar(It is created in a template all pages use):

<h:body>
        <h:form>
        <p:dock position="top">
            <p:menuitem value="Naslovna" icon="unsecuredimages/naslovna.png"
                url="main.xhtml" alt="The image could not be found." />
            <p:menuitem value="Register" icon="unsecuredimages/register.png"
                url="registration.xhtml" alt="The image could not be found." />
            <p:menuitem value="Cesta pitanja" icon="unsecuredimages/faq.png"
                url="faq.xhtml" alt="The image could not be found." />

            <p:menuitem value="Login" icon="unsecuredimages/login.png" url="login.xhtml" rendered ="securityController.checkLogged() == false"/>
        <p:menuitem value="Logout" icon="unsecuredimages/logout.png" action="securityController.logOut()" rendered ="securityController.checkLogged() == true"/>

        </p:dock>   
        </h:form>

This is how the securityController Backing bean looks like:

@ManagedBean
@RequestScoped
public class SecurityController {

    @EJB
    private IAuthentificationEJB authentificationEJB;

    ...

    public boolean checkLogged() {
        return authentificationEJB.checkAuthentificationStatus();
    }

    ...
}

In the process there is also an EJB involved:

@Stateful(name = "ejbs/AuthentificationEJB")
public class AuthentificationEJB implements IAuthentificationEJB {

    @PersistenceContext
    private EntityManager em;

        ....

        // Check if user is logged in
    public boolean checkAuthentificationStatus() {
        // 1-Check if there is something saved in the session(This means the
        // user is logged in)
        if ((FacesContext.getCurrentInstance().getExternalContext()
                .getSessionMap().get("userRole") != null)) {
            // 2-If there is not a user already loged, then return false
            return true;
        }

        return false;
    }

        ...

What do you think how can i add this feature to my nav bar?

Update

<p:menuitem value="Login" icon="unsecuredimages/login.png" url="login.xhtml" rendered ="securityController.checkLogged"/>
            <p:menuitem value="Logout" icon="unsecuredimages/logout.png" action="securityController.logOut()" rendered ="!securityController.checkLogged"/>

i also changed to:

public boolean isCheckLogged() {
        return authentificationEJB.checkAuthentificationStatus();
    }

This is how the navigation looks like. As you see i don’t see login or logout icons.

enter image description here

How can i fix it?

  • 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-21T12:42:18+00:00Added an answer on May 21, 2026 at 12:42 pm

    Instead of c:if use the rendered attribute of p:menuitem (or any other primefaces component).

    Like this:

    <p:menuitem value="Login" icon="unsecuredimages/login.png" url="login.xhtml" rendered="#{securityController.checkLogged}"/>
    <p:menuitem value="Logout" icon="unsecuredimages/logout.png" action="securityController.logOut()" rendered="#{!securityController.checkLogged}"/>
    

    You will need a getCheckLogged() or isCheckLogged() method in your securityController bean. So:

    public boolean getCheckLogged() {
        return authentificationEJB.checkAuthentificationStatus();
    }
    

    EL will translate the securityController.checkLogged attribute reference to a getter method call by naming convention.

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

Sidebar

Related Questions

I use the google map tool from primefaces . I want my user to
Instead of a common navigation bar i use a primefaces tool called dock .
I want to use Primefaces to display a wizard pretty much similar to the
I'm using primefaces 3.1, and I want to use the PrimeFaces Push. I want
I am new to primefaces and I want to use autocomplete tag of primeface.So
I am using Primefaces 3.3.1. My use case is very simple, after login user
I use the Primefaces manual example for a wizard, and replace one of the
I want to ask that sometimes what happen that if I use PrimeFaces Rich
I use PrimeFaces 3.0-SNAPSHOT with JBoss AS7. I put three <p:fileUpload> tags in one
I want to use Primefaces library as osgi bundle in JSF application. I created

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.