私はスプリングブート、プライムフェイス、および休止状態のSTS(スプリングツールスイート)を使用しています。p:selectOneMenu in p:パネルno load save after correct
私はp:datatableを持つページを持っています。最後の列には、表の編集データ用のp:commandbuttonがあります(p:dialog)。 ダイアログを開くと、すべてのデータが正しく読み込まれます。保存せずにダイアログを閉じて、テーブルの他の行を開くとデータが正しく読み込まれますが、データを保存してテーブルの他の行の新しいダイアログを開くと、フィールドp:selectOneMenuに間違ったデータが読み込まれます。値は保存された最後のダイアログと同じ値です。すべてのダイアログデータに正しい、コンボボックス(p:selectOneMenu)がありません。デバッグでは、バッキングBeanに返される値が正しいです。
私が試したいくつかの点:PにCommandButton:
- は、p変更のcommandLinkを。
- ダイアログの "保存"ボタンで、テーブルのp:パネルで "更新"フィールド、h:フォーム、h:データテーブル。
- oncompleteをonClickに変更します。
- p:selectOneMenuの代わりにh:selectOneMenuを使用します。
- ダウングレードプライムフェイス(現在6.1)とマイフェース(現在2.2.12)。
すべて正常ではありません。
ps:Datatableはフィルタ処理され、改ページされます。
XHTML:
<p:panel id="pnlData" header="My Table">
<h:form id="frmTable">
<p:dataTable var="item" value="#{RSDMBean.myData}"
id="tblTicketsID" widgetVar="tabelaTickets" some things of pagination and filters here...>
<p:column />
<p:column /> ...
<p:column headerText="Edit">
<p:commandButton value="Edit"
actionListener="#{RSDMBean.editTicketLoad(item.idTicket)}"
update=":formPnl:pnlTkct" oncomplete="PF('dlgtkt').show();">
</p:commandButton>
</p:column>
</p:datatable>
</h:form
</p:panel>
<p:dialog id="dlgtktID" header="Edit ticket" widgetVar="dlgtkt"
modal="true">
<h:form id="formPnl">
<h:panelGrid id="pnlTkct" columns="2" cellpadding="10"
cellspacing="1" style="absolute">
<h:outputText style="font-weight:bold" value="Id Ticket: " />
<h:outputText value="#{RSDMBean.ticketEdited.id}" />
Others fields here...
<h:outputText style="font-weight:bold" value="County: " />
<p:selectOneMenu style="min-width: 162px;" required="true">
<f:selectItem itemLabel="#{RSDMBean.ticketEdited.county.name}"
itemValue="#{RSDMBean.ticketEdited.county.id}" />
<f:selectItems
value="#{RSDMBean.countyItensedit.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu>
<p:commandButton value="Save" action="#{RSDMBean.saveEdit}"
update=":frmTable:tblTicketsID" oncomplete="PF('dlgtkt').hide();" />
end tags here...
豆:P IN
import javax.annotation.PostConstruct;
import javax.faces.bean.RequestScoped;
import org.springframework.beans.factory.annotation.Autowired;
.
.
.
@Controller("RSDMBean")
@RequestScoped
public class MyMBean implements Serializable {
@Autowired
private ResiduoService residuoService;
@Autowired
private ResiduoRepository residuoRepository;
@Autowired
private CountyRepository countyRepository;
private Residuo ticketEdited;
private List<County> county;
private Map<Long, String> countyItensEdit = new HashMap<Long, String>();
public void editTicketLoad(String param) {
long idTicket = Long.parseLong(param);
ticketEdited = residuoRepository.findOne(idTicket);
county = countyRepository.findAll();
}
@PostConstruct
public void construct() {
//some loads database here...
county = countyRepository.findAll();
if (countyItensEdit.isEmpty()) {
for (Municipio c : countyItensEdit) {
countyItensEdit.put(c.getId(), c.getNome());
}
}
}
あなたは更新属性で間違った値を使用します。アプリを開発モードで実行し、https://stackoverflow.com/questions/8634156/how-to-find-out-client-id-of-component-for-ajax-update-render-cannot-find-compoも読んでください。 – Kukeltje
あなたのリンクや質問など、「更新」属性が更新されました。しかし、働いていない。 – vctlzac