Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces: save to db using ajax for inplace tag
    primarykey
    data
    text
    <p>One more question from me about primefaces (java, jsf). I have ManagedBean with such code:</p> <pre><code>@ManagedBean @SessionScoped public class AccountManagedBean { private Long id = (long) 1; private Account account = new Account(); private AccountJpaController accountController = new AccountJpaController(); public void AccountManagedBean() { extractAccount(); } public void saveAccount() { accountController.update(account); // extract info for page extractAccount(); } public void extractAccount() { account = accountController.get(id); } public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } } </code></pre> <p>And xhtml file - view part:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"&gt; &lt;h:body&gt; &lt;p:panel id="account"&gt; &lt;h:panelGrid columns="2" columnClasses="column" cellpadding="5"&gt; &lt;h:outputText value="Balance: " /&gt; &lt;p:inplace editor="true"&gt; &lt;p:ajax event="save" listener="#{accountManagedBean.saveAccount}" update="account" /&gt; &lt;p:inputText value="#{accountManagedBean.account.balance}" required="true"/&gt; &lt;/p:inplace&gt; &lt;h:outputText value="Credit limit: " /&gt; &lt;p:inplace editor="true" &gt; &lt;p:ajax event="save" listener="#{accountManagedBean.saveAccount}" update="account" /&gt; &lt;p:inputText value="#{accountManagedBean.account.creditLimit}" required="true"/&gt; &lt;/p:inplace&gt; &lt;h:outputText value="Comment: " /&gt; &lt;p:inplace editor="true"&gt; &lt;p:ajax event="save" listener="#{accountManagedBean.saveAccount}" update="account" /&gt; &lt;p:inputText value="#{accountManagedBean.account.comment}"/&gt; &lt;/p:inplace&gt; &lt;/h:panelGrid&gt; &lt;/p:panel&gt; &lt;/h:body&gt; </code></pre> <p>Problem is in saving edited information. I set breakpoint on method saveAccount and try to change values on page. After changing field value on page the program paused on breakpoint and I can see object which is saving to DB - there are old values (which were extracted from db). And on page old values are too (it's reasonable, because "old" account was updated). I use primefaces 3.0.RC2. May be problem is in ajax attribute "event" (I use "save", but in Primefaces users guide I didn't found other variants for such situation). Please help me with my problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload