ฉันมีปัญหาใหญ่กับอินเทอร์เฟซ Primefaces ของฉัน ฉันต้องการวนซ้ำรายการและแสดงข้อมูลบางส่วน + ช่องแก้ไขที่ซ่อนอยู่
ข้อมูลโค้ด XHTML Primefaces:
<p:dataList value="#{datas}" var="data">
<div class="ui-g">
<div class="ui-g-3">
<h2>#{data.desc}</h2>
</div>
<div class="ui-g-3">
<p:commandButton operation="edit" disabled="#{data.isLocked()}" actionListener="#{view.edit(data)}"
style="width:120px;" update="edit_#{data.id}" />
<p:commandButton operation="delete" actionListener="#{view.delete(data.getId())}" disabled="#{data.isLocked()}"/>
</div>
</div>
<!-- works perfectly to set the id -->
<span id="edit_#{data.id}">#{data.desc} #{index}</span>
<!-- doesnt work - maybe of the rendering moment to set the id? -->
<p:panelGrid id="edit_#{data.id}" rendered="#{view.edit}">
<p:outputLabel for="desc" value="#{msg.text}" />
<p:inputText id="desc" value="#{view.selectedValue.desc}" />
</p:panelGrid>
How can I set a dynamic ID to the panelGrid to update it by commandButton click if I want to edit that div? + How can I make the div toggled while editing it? or are there other Solutions? I am not allowed to use JavaScript/jQuery.
ขอบคุณมาก!
ไชโย JohnRamb0r
edit_{data.id}
บางทีนี่อาจเป็นปัญหา คุณได้รับข้อความแสดงข้อผิดพลาดหรือไม่? หากคุณต้องการรหัสเฉพาะสำหรับupdate=
คุณควรใส่<span
และ<p:panelGrid
ไว้ใน<h:panelGroup id='edit_#{data.id}'>
และตัดรหัสของพวกเขาออก - person Holger   schedule 10.01.2019<h:panelGroup id='edit_#{data.id}'>
และไม่มีใครต้องได้รับรหัสเดียวกัน - person Holger   schedule 10.01.2019Cannot find component for expression "edit_1" referenced from "main:j_idt70:0:j_idt122".
คำชี้แจงการอัปเดตกำลังมองหา edit_1 แต่รหัสของ panelgrid ถูกสร้างขึ้นโดย Primefaces: main:j_idt70:0:edit_ แต่ฉันต้องการให้ panelGrid ควรมี id --> edit_1 เดียวกันสำหรับตัวอย่าง - person JohnRamb0r   schedule 10.01.2019:0
คุณจึงไม่จำเป็นต้องใช้รหัสแบบไดนามิก เพียงใช้เช่นeditbox
มันจะเปลี่ยนเป็นmain:j_idt70:x:editbox
โดยที่ x คือดัชนีแถวของ dataList ญาติupdate='editbox'
ที่ไม่มี:
ควรค้นหามัน - person Holger   schedule 10.01.2019update="editbox"
กล่องแก้ไขทุกกล่องจะปรากฏขึ้น - ฉันพูดถูกไหม? - person JohnRamb0r   schedule 10.01.2019