Update inputtext value from datatable

UI Components for JSF
Post Reply
r_1gm
Posts: 3
Joined: 16 Nov 2011, 19:57

16 Nov 2011, 20:15

Hi all,
nice to meet you, i am primefaces newbie, i trying to play with primefaces but i cannot find a way to update a primefaces inputtext from item that selected from a primefaces datatable, can someone please help me ? :roll: thank you in advance :D

oh i forgot to say i'am using primefaces 3 from trunk.

Best Regards,
Rody

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

16 Nov 2011, 22:37

Welcome to the PrimeFaces. Could you post your code snippet what do you try to do?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

17 Nov 2011, 01:21

Refer the URL below. It is any/everything you need to know about manipulating JSF dataTables. It may be older logic, but it is fundamental JSF. I've had to refer to this page to help me do the same. Basically, what you want to do is modify the value in your List<Object> in your bean, and then the value will be displayed on the JSF page/facelet. I had to do the same for using p:dataTable for allowing enduser to modify Address Lines (123 Some Street, Apartment 3, etc...) that belong to an Address data structure.

http://balusc.blogspot.com/2006/06/usin ... ables.html
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

r_1gm
Posts: 3
Joined: 16 Nov 2011, 19:57

17 Nov 2011, 20:39

hi Oleg,

after i try again and look to the primefaces showcase, i already know why yesterday my inputtext not updated with data that selected from datatable(thank you growl :D ), it's caused by required attribute and validation in my POJO, is there a way to bypass the validation and required atributte ?

here is my code :

Code: Select all

<h:body>
        <p:growl id="growl" autoUpdate="true" showDetail="true" />
        <h:form id="carForm">
            <h:panelGrid id="carPanel" columns="2">
                <h:outputLabel value="Name :" for="name" />
                <h:panelGroup id="carGroup">                            
                    <p:inputText id="name" value="#{carController.selected.name}" required="true" />
                    <p:commandButton value="..." onclick="carBrowseDialog.show();" />
                </h:panelGroup>
                <h:outputLabel value="Color :" for="color" />
                <p:inputText id="color" value="#{carController.selected.color}" />
            </h:panelGrid>
        </h:form >
        <p:dialog widgetVar="carBrowseDialog" header="Car List" showEffect="clip" hideEffect="clip">
        <h:form >            
            <p:dataTable value="#{carController.items}" 
                         selection="#{carController.selected}" 
                         selectionMode="single"
                         rowKey="#{item.name}"
                         var="item"
                         paginator="true" rows="10"  
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                         rowsPerPageTemplate="5,10,15">
                <p:column headerText="Name">
                    <h:outputText value="#{item.name}"/>
                </p:column>
                <p:column headerText="Color">
                    <h:outputText value="#{item.color}"/>
                </p:column>                
                <f:facet name="footer">  
                    <p:commandButton value="Select" image="ui-icon ui-icon-search"  
                                     update="carForm:carPanel carForm:color" oncomplete="carBrowseDialog.hide();" />  
                </f:facet>
            </p:dataTable>
        </h:form>
        </p:dialog>
    </h:body>
inputtext with id=color not updated if required = true.

hi smithh032772,
Wow thank you, i need those too, this tutorial very much helping me.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 43 guests