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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:19:12+00:00 2026-06-17T22:19:12+00:00

I have some JSF page and some bean, in cae that it is editing

  • 0

I have some JSF page and some bean, in cae that it is editing curent ellement i use update otherwice i use save methods.

I tryed to debug and think methods on buttons never executes

Here is my JSF page:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Manage panel</title>
    </h:head>
    <h:body>
        <h3>Add/edit patient</h3>
        <h:form>           
            <c:set var="patient" value="#{manageBean.patient}" />
            <c:choose>
                <c:when test="#{patient!=null}">
                    <p:panel id="panel1" header="Patient" style="margin-bottom:10px;">  
                        <h:panelGrid columns="2">  
                            <h:outputLabel for="name" value="First  name" />  
                            <p:inputText id="firstName" required="true" value="#{patient.firstName}" />  

                            <h:outputLabel for="name" value="Family  name" />  
                            <p:inputText id="familyName" required="true" value="#{patient.familyName}" />  

                            <h:outputLabel for="name" value="Sex" />  
                            <p:selectOneMenu id="sex" value="#{patient.sex}">  
                                <f:selectItems value="#{manageBean.sex}"/>
                            </p:selectOneMenu>  

                            <h:outputLabel for="name" value="Birthday date" />  
                            <p:calendar value="#{patient.birthdayDate}" mode="inline" id="birthdayDate"/>  

                            <h:outputLabel for="name" value="Nationality" />  
                            <p:selectOneMenu id="nationality" value="#{patient.nationality}">  
                                <f:selectItems value="#{manageBean.nationality}"/>
                            </p:selectOneMenu>  

                            <h:outputLabel for="name" value="Adress" />  
                            <p:inputText id="adress" required="true" value="#{patient.adress}" />  

                            <h:outputLabel for="name" value="Phone number" />  
                            <p:inputMask id="phoneNumber" required="true" value="#{patient.phoneNumber}" mask="(999) 999-9999"/>
                        </h:panelGrid>  
                    </p:panel>  
                    <p:commandButton value="Update" type="submit" action="#{manageBean.update(patient)}" />  
                </c:when>   
                <c:otherwise>
                    <p:panel id="panel2" header="Patient" style="margin-bottom:10px;">  
                        <h:panelGrid columns="2">  
                            <h:outputLabel for="name" value="First  name" />  
                            <p:inputText id="firstName" required="true" value="" />  

                            <h:outputLabel for="name" value="Family  name" />  
                            <p:inputText id="familyName" required="true" value="" />  

                            <h:outputLabel for="name" value="Sex" />  
                            <p:selectOneMenu id="sex" value="">  
                                <f:selectItems value="#{manageBean.sex}"/>
                            </p:selectOneMenu>  

                            <h:outputLabel for="name" value="Birthday date" />  
                            <p:calendar mode="inline" id="birthdayDate"/>  

                            <h:outputLabel for="name" value="Nationality" />  
                            <p:selectOneMenu id="nationality" value="">  
                                <f:selectItems value="#{manageBean.nationality}"/>
                            </p:selectOneMenu>  

                            <h:outputLabel for="name" value="Adress" />  
                            <p:inputText id="adress" required="true" value="" />  

                            <h:outputLabel for="name" value="Phone number" />  
                            <p:inputMask id="phoneNumber" required="true" value="" mask="(999) 999-9999"/>
                        </h:panelGrid>  
                    </p:panel>  
                    <p:commandButton value="Save" action="#{manageBean.save(firstName, familyName, sex, birthdayDate, nationality, adress, phoneNumber)}" />  
                </c:otherwise>
            </c:choose>
        </h:form>      
    </h:body>
</html>

Here is my bean methods:

   public String update(Patient patient) {       
        Session session = factory.openSession();
        Transaction tx = null;
        try {
            tx = session.beginTransaction();
            session.update(patient);
            tx.commit();
        } catch (HibernateException ex) {
            if (tx != null) {
                tx.rollback();
            }
            ex.printStackTrace();
        } finally {
            session.close();
        }
        return "go_home";
    }

    public String save(String fitstName, String familyName, Sex sex, Date birthdayDate, Nationality nationallity, String adress, String phoneNumber){
        Session session = factory.openSession();
        Transaction tx = null;
        try {
            tx = session.beginTransaction();
            Patient patient = new Patient();
            patient.setFirstName(fitstName);
            patient.setFamilyName(familyName);
            patient.setSex(sex);
            patient.setBirthdayDate(birthdayDate);
            patient.setNationality(nationallity);
            patient.setAdress(adress);
            patient.setPhoneNumber(phoneNumber);
            session.save(patient);            
            tx.commit();
        } catch (HibernateException ex) {
            if (tx != null) {
                tx.rollback();
            }
            ex.printStackTrace();
        } finally {
            session.close();
        }
        return "go_home";
    }
  • 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-17T22:19:13+00:00Added an answer on June 17, 2026 at 10:19 pm

    Once u give the value attribute in your input tags it ll directly bind the given values to the java class. Create the class variables in ur java class and bind the input tags. EX:-
    In your bean class create variables like

    private String firstName 
    

    and create the getter and setter methods

    <f:view>
    
        <h3>Add/edit patient</h3>
    
        <h:form>           
                    <p:panel id="panel1" header="Patient" style="margin-bottom:10px;">  
    
                        <h:panelGrid columns="2">
                            <h:outputLabel for="name" value="First  name" />
                            <p:inputText id="firstName" required="true" value="#{manageBean.firstName}" />
    
                            <h:outputLabel for="name" value="Family  name" />  
                            <p:inputText id="familyName" required="true" value="#{manageBean.familyName}" />  
    
                            <h:outputLabel for="name" value="Sex" />  
                            <p:selectOneMenu id="sex" value="#{manageBean.sex}">  
                                <f:selectItems value="#{manageBean.sex}"/>
                            </p:selectOneMenu>  
    
                            <h:outputLabel for="name" value="Birthday date" />  
                            <p:calendar value="#{manageBean.birthdayDate}" mode="inline" id="birthdayDate"/>  
    
                            <h:outputLabel for="name" value="Nationality" />  
                            <p:selectOneMenu id="nationality" value="#{manageBean.nationality}">  
                                <f:selectItems value="#{manageBean.nationality}"/>
                            </p:selectOneMenu>  
    
                            <h:outputLabel for="name" value="Adress" />  
                            <p:inputText id="adress" required="true" value="#{manageBean.adress}" />  
    
                            <h:outputLabel for="name" value="Phone number" />  
                            <p:inputMask id="phoneNumber" required="true" value="#{manageBean.phoneNumber}" mask="(999) 999-9999"/>
                        </h:panelGrid>  
                    </p:panel>  
                    <p:commandButton value="Update" type="submit" action="#{manageBean.update}" />  
    
                        </h:form> 
    

    Create a new jsp page and copy-paste these codes inside body tag.
    In your java class create the variables and getter setter methods.
    Update should be a method which returns a string.

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

Sidebar

Related Questions

I have a JSF page with some common elements and then 4 parts that
I have got some problems with my JSF page, and (probably) with backing bean.
I have some JSF page and some manage bean. In manage bean I create
We have a custom JSF component that renders some buttons and a select box
I have some arbitrary pixel data that I want to save as a PNG.
I have a pretty complex JSF page (we use JSF2 with facelet) in which
I have a JSF 2.0 application(App#1) that has a managed Session Scoped bean that
I have a JSF 2 composite component that employs some Ajax behavior. I want
I have a JSF page that includes a tree form tag which is rendered
I'm using JSF 2 and PrimeFaces 2.1 on GlassFish. I have a page that

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.