primefaces datatable-dialog für die änderung von Daten

Dies ist mein Erster Beitrag. Diese Website und alle beteiligten Personen sind wunderbar. Vielen Dank an alle. Mein problem: ich habe eine datatable mit einem dialog, der zeigt Informationen über das ausgewählte register. Das funktioniert auch. Aber wenn ich versuche, verwenden Sie den dialog für die änderung von Informationen, die das Feld zeigt nicht die Informationen. Eclipse Juno 2EE, Primefaces 3.5, mit jsf2 und Tomcat 7.0.39. Java-7.0.07 64 bit.

Admin Seite.xhtml
....

<h:form id="adminform" preempId="false">
....
<div id="datos">
<p:panel id="panelData" style="height: 100%; width: 100%; margin-left: auto; margin-right: 0; border: none; background: transparent;">
    <ui:include src= "#{adminBean.pageSelected}" />
</p:panel>
</div>
</div>
</h:form>

Seite adminusers.xhtml geladen ui:include

<p:panel id="usuarios" header="USUARIOS" style="background: transparent; border: 1; width: 850px;">
    <p:commandButton value="Nuevo usuario" type="button" onclick="newuser.show()" immediate="true"/>
    <br /><br />
    <p:dataTable id="usertable" var="data" value="#{DTableCustomerBean.datos}" emptyMessage="Sin datos."
                resizableColumns="true" style="text-align: center; align: center; border-radius: 1.6em;"
                selection="#{DTableCustomerBean.selectedCustomer}" selectionMode="single" rowKey="#{data.id}" >
        <p:columns value="#{DTableCustomerBean.columns}" var="column" columnIndexVar="colIndex" 
                        width="#{column.width}">
            <f:facet name="header">#{column.header}</f:facet>
            <h:outputText value="#{data[column.property]}" />
        </p:columns>
        <p:column style="width: 80px;">
            <p:commandLink update=":adminform:showuserform" oncomplete="showuser.show()" immediate="true" 
                            title="Ver" style="margin-right: 10px;">
                <img src="images/info.png" style="width: 20px; height: 20px; border: 0px;"/>
                <f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
            </p:commandLink>  
            <p:commandLink update=":adminform:edituserform" oncomplete="edituser.show()" immediate="true" 
                            title="Modificar" style="margin-right: 10px;">
                <img src="images/modificar.png" style="width: 20px; height: 20px; border: 0px;"/>
                <f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
            </p:commandLink>
            <p:commandLink update=":adminform:showuserform" oncomplete="showuser.show()" immediate="true" 
                            title="Borrar" style="margin-right: 10px;">
                <img src="images/delete.png" style="width: 20px; height: 20px; border: 0px;"/>
                <f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
            </p:commandLink> 
        </p:column>
    </p:dataTable>



<p:dialog id="edituserdlg" header="Modificar datos" widgetVar="edituser" resizable="FALSE" modal="TRUE">
        <h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage" />
        <h:panelGrid id="edituserform" columns="2"  cellpadding="4" cellspacing="4" 
                                                    style="font-size:16px; align: center; margin: 0 auto;" >
            <h:outputText value="Identificador:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.id}" style="font-weight: bold;" />
            <h:outputText value="Nombre:" />
            <p:inputText id="edtnombre" value="#{DTableCustomerBean.selectedCustomer.nombre}" size="20" maxlength="20" 
                                style="font-weight: bold;" />
            <h:outputText value="Apellido:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.apellido}" style="font-weight: bold;" />
            <h:outputText value="Empresa:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.empresa}" style="font-weight: bold;" />
            <h:outputText value="Dirección:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.direccion}" style="font-weight: bold;" />
            <h:outputText value="Rut:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.rut}" style="font-weight: bold;" />
            <h:outputText value="Teléfonos:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.telefonos}" style="font-weight: bold;" />
            <h:outputText value="Usuario:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.usuario}" style="font-weight: bold;" />
            <h:outputText value="Permisos:" />
            <h:outputText value="#{DTableCustomerBean.selectedCustomer.tipoUsuario}" style="font-weight: bold;" />

        </h:panelGrid>
        <p:panel style="margin-left: 30px; display: block; margin: 0 auto; text-align: center; background: transparent; border: 0;">
            <p:commandButton value="Modificar" type="submit" oncomplete="edituser.hide()" update="usuario" />
            <p:commandButton value="Cancelar" type="button" onclick="edituser.hide()" style="margin-left: 30px;"/>
        </p:panel>

....

Zurück Bohne

@ManagedBean(name="DTableCustomerBean")
//@RequestScoped
//@SessionScoped
@ViewScoped
public class DTableCustomerBean implements Serializable {

    private static final long serialVersionUID = 1L;
    private List<ColumnModel> columns;
    private List<Customer> datos;

    private String columnName;
    private Customer selectedCustomer;

    public DTableCustomerBean() {
        System.out.println("Inicia DTableCustomerBean");
        createColumns();
        addData();
    }



    //Getters and Setters
    public List<ColumnModel> getColumns() {
        return columns;
    }
    public void setColumns(List<ColumnModel> columns) {
        this.columns = columns;
    }
    public List<Customer> getDatos() {
        return datos;
    }
    public void setDatos(List<Customer> datos) {
        this.datos = datos;
    }
    public String getColumnName() {
        return columnName;
    }
    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }
    public Customer getSelectedCustomer() {
        return selectedCustomer;
    }
    public void setSelectedCustomer(Customer selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    //Fin Getters and Setters


    private void createColumns() {

        System.out.println("DTableCustomerBean createColumns");
        columns = new ArrayList<ColumnModel>();
        columns.add(new ColumnModel("Nombre", "nombre", 100));
        columns.add(new ColumnModel("Apellido", "apellido", 100));
        columns.add(new ColumnModel("Empresa", "empresa", 150));
        columns.add(new ColumnModel("Teléfonos", "telefonos", 150));
        columns.add(new ColumnModel("Usuario", "usuario", 50));
    }



    static public class ColumnModel implements Serializable {
        private static final long serialVersionUID = 1L;

        private String header;
        private String property;
        private int width;

        public ColumnModel(String header, String property, int width) {
            this.header = header;
            this.property = property;
            this.width = width;
        }

        public String getHeader() {
            return header;
        }

        public String getProperty() {
            return property;
        }

        public int getWidth() {
            return width;
        }
    }

    private void addData() {
        UserDAO userdao;

        System.out.println("DTableCustomerBean addData");
        userdao = new UserDAO();
        datos = new ArrayList<Customer>();
        datos = userdao.getAllCustomers();
    }
}

Die Daten in den outputText Felder korrekt angezeigt. Der Bereich inputText id="edtnombre" leer angezeigt, anstatt mit dem Namen. Natürlich, wenn ich den inputText für einen outputText es funktioniert ok.

Habe ich googgled nach einer Lösung und nichts gefunden. Ich habe versucht, verschiedene Ideen, aber es hat nicht geklappt.

Wer kann helfen? Danke!

Gut. Ich habe das problem gefunden. Eclipse-web-navigator hat nicht funktioniert gut in diesem Fall. Jetzt ist es funktioniert ok. Scheint, es braucht einige Zeit, nachdem die datatable ist gezeigt in der Seite, um korrekt zu arbeiten. Vielleicht ist ein Problem mit Eclipse.

InformationsquelleAutor Augusto | 2013-05-10

Schreibe einen Kommentar