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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:22:45+00:00 2026-06-18T08:22:45+00:00

i have a datatable with one row , i need to edit the fields

  • 0

i have a datatable with one row , i need to edit the fields of this row so i have a few inputText with the values, but when i edit them and click on the commandbutton(that calls the method “actualizarUsuario” the values are passed as null.

this is my bean code:

@ManagedBean(name = "user")
@ViewScoped
public class userDetalles implements Serializable {



    private Usuario u;
    private usuarioController controlador;
    Rol rol;

    private long selection;
    private long selectionrol;
    Agrupacion agrupacion;
    private Privilegio privilegio;
    private RolController controladorRol;
    private ControladorAgrupaciones controladorAgrup;
    private String nombres;
    private String apellidoP;
    private String apellidoM;
    private Boolean check;

    @PostConstruct
    public void init() {

       rol= new Rol() ;
       u=new Usuario();
       agrupacion=new Agrupacion();
       privilegio=new Privilegio();
       controlador= new usuarioController();
       controladorRol=new RolController();
       controladorAgrup=new ControladorAgrupaciones();
       Usuario u=new Usuario();
       FacesContext facesContext = FacesContext.getCurrentInstance();
       ExternalContext externalContext = facesContext.getExternalContext();

        //Obtener parametros del request
       Map<String, String> parameterMap = (Map<String, String>) externalContext.getRequestParameterMap();
       long iduser = Long.valueOf(parameterMap.get("id_usuario"));

       this.u=controlador.getUser(iduser);
    }

    public Usuario getU() {
        return u;
    }

    public void setU(Usuario u) {
        this.u = u;
    }

    public long getSelection() {
        System.out.println("selection value----------->"+selection);
        return selection;
    }

    public void setSelection(long selection) {
        this.selection = selection;
    }

    public long getSelectionrol() {
        return selectionrol;
    }

    public void setSelectionrol(long selectionrol) {
        this.selectionrol = selectionrol;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public String getApellidoP() {
        return apellidoP;
    }

    public void setApellidoP(String apellidoP) {
        this.apellidoP = apellidoP;
    }

    public String getApellidoM() {
        return apellidoM;
    }

    public void setApellidoM(String apellidoM) {
        this.apellidoM = apellidoM;
    }

    public Boolean getCheck() {
        return check;
    }

    public void setCheck(Boolean check) {
        this.check = check;
    }


    public void actualizarUsuario(){

        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, String> parameterMap = (Map<String, String>)   externalContext.getRequestParameterMap();
        nombres=parameterMap.get("nombres");
        apellidoP=parameterMap.get("apellidoP");
        apellidoM=parameterMap.get("apellidoM");
        check=Boolean.parseBoolean(parameterMap.get("check"));
        //test
        System.out.println(nombres+" "+apellidoP+" "+apellidoM+" "+check);
        u.setNombres(nombres);
        u.setApellidoPaterno(apellidoP);
        u.setApellidoMaterno(apellidoM);
        u.setActive(check);
        controlador.saveUsuario(u);
    }



}

and this is my view:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <div class="container">
        <h:panelGroup id="Users">
            <h:form id="Form">
                <h2>Detalles Usuario</h2>

                <h:dataTable id="users" value="#{user.u}"  styleClass="table table-striped table-bordered" headerClass="sorting_asc"
                             rowClasses="odd,even">
                    <h:column>
                        <f:facet name="header">#</f:facet>
                        #{user.u.id}
                    </h:column>
                    <h:column>
                        <f:facet name="header">Identificador</f:facet>
                        <h:inputText id="identificador" value="#{user.u.identificador}" />
                    </h:column>
                    <h:column>
                     <f:facet name="header">Nombre</f:facet>

                     <h:inputText id="nombres" value="#{user.u.nombres}"/>
                     <h:inputText id="apellidoP" value="#{user.u.apellidoPaterno}"/>
                     <h:inputText id="apellidoM" value="#{user.u.apellidoMaterno}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">Active</f:facet>
                        <h:selectBooleanCheckbox id="check" value="#{user.u.active}"></h:selectBooleanCheckbox>
                    </h:column>

                </h:dataTable>

                <h:commandButton  value="Actualizar" type="submit" styleClass="btn-primary" actionListener="#{user.actualizarUsuario}">
                </h:commandButton>
 </h:form>
            <script type="text/javascript" src="js/paging-bootstrap.js"></script>
            <script type="text/javascript" src="js/contenidoc.datatable.init.js"></script>
        </h:panelGroup>
    </div>
</ui:composition>
  • 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-18T08:22:45+00:00Added an answer on June 18, 2026 at 8:22 am

    Your concrete problem is caused because you used the wrong parameter names. Look in the generated HTML output and the HTTP traffic monitor for the right parameter names.

    However, your actual problem is bigger: your view/model approach is completely wrong. You shouldn’t be using a <h:dataTable> at all. It is intented for a collection of entities like List<User>, not for a single entity like User. You should be using <h:panelGrid>. You don’t need to explode/flatten model properties in controller at all. You have those properties already in the model itself. You don’t need to manually traverse the request parameter map. JSF will already do all the job for you.

    I won’t rewrite this mess for you, but to the point you should follow the following kickoff example:

    Model:

    public class User {
    
        private Long id;
        private String username;
        private String firstname;
        private String lastname;
        // ...
    
        // Autogenerate standard getters/setters.
    }
    

    Controller:

    @ManagedBean
    @ViewScoped
    public class EditUser {
    
        private User user; // Initialize it in postconstruct or as viewparam.
        private UserService service; // Initialize it as @EJB or in postconstruct.
    
        public void save() {
            service.save(user); // That's all. Really.
        }
    
        public User getUser() {
            return user;
        }
    
        // No other getters/setters! They are all already in User class.
    }
    

    View:

    <h:panelGrid>
        <h:inputText value="#{editUser.user.username}" />
        <h:inputText value="#{editUser.user.firstname}" />
        <h:inputText value="#{editUser.user.lastname}" />
        <h:commandButton value="save" action="#{editUser.save}" />
    </h:panelGrid>
    

    That’s all. See also among others this JSF 2.0 tutorial. As to your attempt to get the user by ID, you should rather use <f:viewParam>, see also What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for? and communication in JSF 2.0.

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

Sidebar

Related Questions

I have acefaces datatable with file names, one on row and I'm trying to
I have a simple DataTable where one of the columns contains unique values. For
I can't seem to find this anywhere. I have a dataTable like this one
I have one datatable. In that table I have columns named [Total Day], [Present
I have a dataset with one datatable. Now I want to set a filter
I have one sqlserver 2008 r2 datatable, it has one column autoId int identity(1,1),
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I have a data.table object similar to this one library(data.table) c <- data.table(CO =
I have datatable with column name tag and 100 rows of data.I need to
I have a DataTable in memory that I need to dump straight into a

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.