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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:08:41+00:00 2026-06-13T07:08:41+00:00

I have a JSF page with a button and a label. When the user

  • 0

I have a JSF page with a button and a label. When the user presses the simulateYearButton button, the value displayed in the label yearLabel should be incremented.

The form with the button and the label looks like this:

    <h:form>
        <p:commandButton value="Заресетить" id="resetButton"
            actionListener="#{entryPage.resetButtonAction}" />

        <p:commandButton value="Просимулировать год" id="simulateYearButton"
            actionListener="#{entryPage.simulateYearButtonAction}">
            <f:ajax event="click" render="yearLabel" />
        </p:commandButton>


        <h:outputLabel id="yearLabelLabel" for="yearLabel" value="Год:" />
        <h:outputLabel id="yearLabel" value="#{entryPage.yearLabel}"
            style="font-weight:bold" />
    </h:form>

Code of the entryPage bean:

@ManagedBean(name = "entryPage")
@RequestScoped
public class EntryPageController {
    ...
    private int year;
    private String yearLabel;

    @PostConstruct
    public void init()
    {
        this.yearLabel = "2012";
    }

    ...

    public void simulateYearButtonAction() {
        LOGGER.debug("EntryPageController.simulateYearButtonAction");
        this.year++;
        this.yearLabel = Integer.toString(this.year);
    }

    public String getYearLabel() {
        return yearLabel;
    }
}

When I press the simulateYearButton, the method simulateYearButtonAction is executed (I see the log message in the output), but the label is not updated.

How should I modify the code so that the label is updated, when I press the button?

  • 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-06-13T07:08:42+00:00Added an answer on June 13, 2026 at 7:08 am

    New answer:

     <p:commandButton value="Просимулировать год" id="simulateYearButton"
          actionListener="#{entryPage.simulateYearButtonAction}" update="yearLabel">
     </p:commandButton>
    

    Because commandbutton is ajaxed by default.

    Next, you need to make the bean @ViewScoped.
    Next, you need to assign to year the value of yearLabel :

     @PostConstruct
    public void init()
    {
        this.yearLabel = "2012";
        this.year = Integer.parseInt(yearLabel);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i have JSF page <h:body> <h:form id=formID prependId=false> <h:outputText id=randomID value=#{randomNumber.random}/> <h:commandButton id=buttonID
I have jsf page: .... <form jsfc=h:form action=> <h:dataTable value=#{newMusician.strings} var=preferredMusicGenre id=musicGenresSelectTable> <h:column> <h:inputText
I have the following JSF 2.1 page <h:selectOneRadio value=#{userBean.newUser}> <f:selectItem itemValue=0 itemLabel=new User />
I have an inputText and a commandButton in a JSF page. The user inputs
In my .xhtml page, I have the following form: <ui:composition xmlns:ui=http://java.sun.com/jsf/facelets template=./../template/CustomerTemplate.xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:f=http://java.sun.com/jsf/core
I have a JSF page that includes a tree form tag which is rendered
HI all i have a input field on my jsf page whose value is
I have an input in my jsf page like this <html:inputText id=ResponseOK value=#{bean.ResponseOK} binding=#{bean.ResponseOKInput}
I have a JSF/Seam web app which has a page with a form which,
I have a JSF 2.0 page that uses Primefaces p:dialog component. The user can

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.