-1

How I can edit data in form? I have this Primefaces dialog which hI wants to use to edit data.

<p:dialog header="System User Details" widgetVar="carDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="true">
                        <p:outputPanel id="carDetail" style="text-align:center;">
                            <p:panelGrid  columns="2" rendered="#{not empty systemusers.selectedSystemUser}" columnClasses="label,value">

                                <h:outputText value="Username" />
                                <h:outputText value="#{systemusers.selectedSystemUser.username}" />

                                <h:outputText value="Last Login" />
                                <h:outputText value="#{systemusers.selectedSystemUser.lastLogin}" />

                                .........

                                <h:outputText value="Action" />
                                <h:outputText value="Download Delete" />

                            </p:panelGrid>
                        </p:outputPanel>
                    </p:dialog>
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • Peter, the number of questions you ask, the quality of them and the little feedback you give on the ones we comment on, made me decide to directly downvote this question. You state you want to use the dialog to edit data but there are only outputs. The is no broader attempt (again no [mcve] for an actual coding problem). All you post is something that we should implement for you. I could write an answer stating 'Use `h:inputText` instead of `h:outputText`' and it would be **the** valid answer... – Kukeltje Jul 05 '17 at 20:58
  • 1
    @Kukeltje Probably we are chatting here more than 2 years. I don't remember any useful answer from you except useless spam. – Peter Penzov Jul 05 '17 at 21:03
  • 3
    @Kukeltje Are you getting paid for answering here questions? I see that your are taking this as personal problem. – Peter Penzov Jul 06 '17 at 05:34
  • Why not change the `outputText ` with `inputText` and add a confirm button ?!? – Yagami Light Jul 06 '17 at 06:53
  • Possible duplicate of [How to send form input values and invoke a method in JSF bean](https://stackoverflow.com/questions/3681123/how-to-send-form-input-values-and-invoke-a-method-in-jsf-bean) – Kukeltje Jul 06 '17 at 11:29

1 Answers1

0

Firstly you would need to have an <h:form /> component inside of the <p:dialog /> component tags. You would also need to change the outputText components to that of inputText.

You could use a <p:commandButton to confirm and persist the input. For example:

<p:dialog header="System User Details" widgetVar="carDialog" modal="true" appendTo="@body">
  <h:form id="dialogForm">
      <p:outputLabel for="username" value="Username">
      <p:inputText id="username" value="#{systemusers.selectedSystemUser.username}" required="true" requiredMessage="Value is required" label="Username" />
       ....

      <p:commandButton value="Submit" update=":mainForm" actionListener="#{beanName.updateData}" oncomplete="PF('cardDialog').hide()" />
      <p:commandButton value="Cancel" type="button" onclick="PF('cardDialog').hide()" />
  </h:form>
</p:dialog>
  • 1
    Adding a from inside a dialog is only needed if the dialog is outside a form. If it already is in a form it is not needed. If it has `appendTo="@body"` a form is needed but then it already most be outside a form. OP does not have this `appendTo` so it is not specifically needed. Secondly, and that is not your problem, OP has several questions where he has demonstrated to have knowledge about commandButton's and input fields. Hence these kinds of questions are strange to say the least.... But technically your answer is correct, but the Q is also technically a duplicate... I marked it as such – Kukeltje Jul 06 '17 at 11:29
  • And OP has many Q/A which are effectively duplicates... cheers – Kukeltje Jul 06 '17 at 11:30