How to create editable <h:panelGrid>
===

I found this [example][1] how to create editable `h:datatable` in JSF page.

I want to create something similar but with `h:panelGrid`:


    <h:panelGrid columns="2">
    
        <h:panelGroup>User ID</h:panelGroup>
        <h:panelGroup>
            <h:outputText value="#{AccountProfileController.settings['USERID']}"/>
            <h:inputText value="#{AccountProfileController.settings['USERID']}"/>
        </h:panelGroup>
    
        <h:panelGroup>Group ID</h:panelGroup>
        <h:panelGroup>
            <h:outputText value="#{AccountProfileController.settings['GROUPID']}"/>
            <h:inputText value="#{AccountProfileController.settings['GROUPID']}"/>
        </h:panelGroup>
    
        <h:panelGroup>Special Number</h:panelGroup>
        <h:panelGroup>
            <h:outputText value="#{AccountProfileController.settings['SPECIALNUMBER']}"/>
            <h:inputText value="#{AccountProfileController.settings['SPECIALNUMBER']}"/>
        </h:panelGroup>
    
        <h:panelGroup>Username</h:panelGroup>
        <h:panelGroup>
            <h:outputText value="#{AccountProfileController.settings['USERNAME']}"/>
            <h:inputText value="#{AccountProfileController.settings['USERNAME']}"/>
        </h:panelGroup>
    </h:panelGrid>     

The managed bean:

    import javax.sql.DataSource;
    import javax.annotation.Resource;
    import javax.faces.bean.ViewScoped;
    import javax.faces.context.FacesContext;
    
    import org.glassfish.osgicdi.OSGiService;
    
    @Named("AccountProfileController")
    @ViewScoped
    public class AccountProfile implements Serializable {
    
        @Resource(name = "jdbc/Oracle")
        private DataSource ds;
        
        private int id;
        // This Hash Map will be used to store setting and value
        private HashMap<String, String> settingsMap = new HashMap<>();
    
        public HashMap<String, String> getsettings()
        {
            return settingsMap;
        }
    
        public AccountProfile()
        {
            // get the ID value 
            try
            {
                this.id = Integer.parseInt((String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
            }
            catch (Exception e)
            {
                this.id = 0;
            }
        }
    
        @PostConstruct
        public void initData() throws SQLException
        {
            //     settingsMap = new HashMap<String, String>();
    
            if (ds == null)
            {
                throw new SQLException("Can't get data source");
            }
            // Initialize a connection to Oracle
            Connection conn = ds.getConnection();
    
            if (conn == null)
            {
                throw new SQLException("Can't get database connection");
            }
            // With SQL statement get all settings and values
            PreparedStatement ps = conn.prepareStatement("SELECT * from USERS where USERID = ?");
            ps.setInt(1, id);
            try
            {
                //get data from database        
                ResultSet result = ps.executeQuery();
                while (result.next())
                {
                    // Put the the data from Oracle into Hash Map                
                    settingsMap.put("USERID", result.getString("USERID"));
                    settingsMap.put("GROUPID", result.getString("GROUPID"));
                    settingsMap.put("SPECIALNUMBER", result.getString("SPECIALNUMBER"));
                    settingsMap.put("USERNAME", result.getString("USERNAME"));
                    settingsMap.put("PASSWD", result.getString("PASSWD"));
                    settingsMap.put("DATETOCHANGEPASSWD", result.getString("DATETOCHANGEPASSWD"));
                    settingsMap.put("ADDRESS", result.getString("ADDRESS"));
                    settingsMap.put("STATEREGION", result.getString("STATEREGION"));
                    settingsMap.put("COUNTRY", result.getString("COUNTRY"));
                    settingsMap.put("USERSTATUS", result.getString("USERSTATUS"));
                    settingsMap.put("TELEPHONE", result.getString("TELEPHONE"));
                    settingsMap.put("DATEUSERADDED", result.getString("DATEUSERADDED"));
                    settingsMap.put("USEREXPIREDATE", result.getString("USEREXPIREDATE"));
                    settingsMap.put("DATEUSERLOCKED", result.getString("DATEUSERLOCKED"));
                    settingsMap.put("CITY", result.getString("CITY"));
                    settingsMap.put("EMAIL", result.getString("EMAIL"));
                    settingsMap.put("DESCRIPTION", result.getString("DESCRIPTION"));
                }
            }
            finally
            {
                ps.close();
                conn.close();
            }
        }
        
        // Editable
        boolean editable;
    
        public boolean isEditable()
        {
            return editable;
        }
    
        public void setEditable(boolean editable)
        {
            this.editable = editable;
        }
    }

The JSF page into the example uses `alue="#{order.orderList}" var="o"` to display the data. In my case I use Java `hashmap` to display the data, I don't know how to do this with `hashmap`. Can you tell me in my case how I can create editable `h:panelGrid`?

Best wishes





















  [1]: http://www.mkyong.com/jsf2/how-to-update-row-in-jsf-datatable/