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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:25:41+00:00 2026-06-07T09:25:41+00:00

I am using JSF’s java classes to create UI elements for a simple HTML

  • 0

I am using JSF’s java classes to create UI elements for a simple HTML page as shown below. However the methods Bean::save() and Item.setValue(…) aren’t executed.

item.xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Test</title>
    </h:head>
    <h:body>
        <h:panelGroup binding="#{bean.htmlPanelGroup}" />
    </h:body>
</html>

Bean.java

@ManagedBean(name="bean")
@ViewScoped
public class Bean implements Serializable {
    private final Item item = new Item(1L, "hello");

    public void save() {
        // this method is not executed when the save button created below is clicked.
        System.out.println("item.value = " + item.getValue());
    }

    public Item getItem() { return this.item; }

    transient HtmlPanelGroup htmlPanelGroup;

    public void setHtmlPanelGroup(HtmlPanelGroup htmlPanelGroup) {
        this.htmlPanelGroup = htmlPanelGroup;
    }
    public HtmlPanelGroup getHtmlPanelGroup() {
        if (htmlPanelGroup == null) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            htmlPanelGroup = new HtmlPanelGroup();
            HtmlForm editForm = new HtmlForm();
            HtmlInputText value = new HtmlInputText();
            ValueExpression valueExpr = facesContext.getApplication().getExpressionFactory()
            .createValueExpression(facesContext.getELContext(), "#{bean.item.value}", String.class);
            value.setValueExpression("value", valueExpr);
            editForm.getChildren().add(value);
            HtmlCommandButton save = new HtmlCommandButton();
            save.setValue("save");
            MethodExpression methodExpr = facesContext.getApplication().getExpressionFactory()
            .createMethodExpression(facesContext.getELContext(), "#{bean.save}", String.class, new Class<?>[]{});
            save.setActionExpression(methodExpr);
            editForm.getChildren().add(save);
            htmlPanelGroup.getChildren().add(editForm);
        }
        return htmlPanelGroup;
    }
}

Item.java

public class Item implements Serializable {
    private long id;
    private String value;

    public Item(long id, String value) {
        this.id = id;
        this.value = value;
    }

    public String getValue() { return value; }

    public void setValue(String value) { this.value = value; }

    public long getId() { return id; }

    public void setId(long id) { this.id = id; }
}
  • 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-07T09:25:43+00:00Added an answer on June 7, 2026 at 9:25 am

    All programmatically created JSF UIForm, UIInput and UICommand components needs to have a fixed ID set, otherwise JSF would autogenerate one which doesn’t get saved and then JSF won’t be able to extract the submitted values based on those IDs from the request parameter map.

    So, in your particular case, you need to add the following lines (the ID is fully free to your choice):

    editForm.setId("form");
    // ...
    value.setId("value");
    // ...
    save.setId("save");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JSF 2.0 Mojarra. I need to create a Managed Bean that
Simple question (using JSF 2.0 and primefaces 2.2.1): I need to create a button
I am using JSF 2 and RichFaces 3. Here in the picture shown below,
I am using JSF to render an HTML page. I design the page like
I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean
I'm using JSF 2.0 with Facelets in a Java EE 6 application server (GlassFish
I am using JSF 2.1.1. I have a sample JSF page that is used
i am using jsf 2.0 i have question accoring to PreRenderView. in my Bean
i am using jsf 2.1.1 and primefaces 3.0.M4. i have a sample jsf page
Using a commandButton in a jsf Page to download a file. Using: JSF &

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.