1

I'm using PF 5.3, with JSF 2.2

I have a p:commandButton which exists in one of p:column of a p:dataTable. I have a panel outside the dataTable and I want it to be updated once the commandButton is clicked, but this didn't work.

xhtml sample:

<h:form id="register_edit_student" enctype="multipart/form-data" >
  <p:dataTable var="students" value="#{generalPresentation.students}">
    <p:column headerText="Edit">
      <p:commandButton update="updateStudent" value="Edit" action="#{teacherPresentation.assignEditableStudent(students)}" />
    </p:column>
  </p:dataTable>

  <p:panel id="updateStudent">
  </p:panel>
</h:form>

My requirement is to update the "updateStudent" p:panel. Once I ask the p:commandButton to update the panel (update="updateStudent") the page design crashed and all controls disappeared.

I was reading in the internet the commandButton of a column in a dataTable cannot update anything outside the dataTable, so the question, is there a solution or work around?

Thanks

John
  • 55
  • 1
  • 9
  • `update=":register_edit_student:updateStudent"` doesn't work either? – ForguesR Jan 02 '16 at 17:00
  • This works, thanks. The page not crushing anymore, but still I couldn't load the new values into the panel. – John Jan 02 '16 at 17:04
  • Where did you read that a commandButton in a dataTable cannot update anything outside a dataTable? That site should be taken offline for spreading misleading and plain wrong information – Kukeltje Jan 02 '16 at 19:41
  • Why did you accept an answer if it still does not work? (Ok, it does not 'crush' anymore, but still updatingdoes not work) – Kukeltje Jan 02 '16 at 19:42

1 Answers1

0

You have three options to solve this:

  1. add prependId="false" to your form,
  2. Prepend the form id in your reference: update=":register_edit_student:updateStudent" or
  3. move your panel outside of the form element.

Note: The first option should be used rarely and is known to cause issues with plain JSF.

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
  • Some good background information: http://stackoverflow.com/a/7416770/1725096 – Jens Piegsa Jan 02 '16 at 17:19
  • `prependId='false'` has **no** effect in ajax updates. In that case you still need to prepend all id's, so this is not a good solution: http://stackoverflow.com/questions/7415230/uiform-with-prependid-false-breaks-fajax-render – Kukeltje Jan 02 '16 at 19:34
  • @Kukeltje: This may apply to plain JSF, but could not be replicated regarding the PrimeFaces component p:commandButton. Actually I tried all three proposed options with the given code snippet and two mocks (GeneralPresentation and TeacherPresentation): all three work. – Jens Piegsa Jan 02 '16 at 21:42
  • Hmmm seriously? Need to check that since I'm (almost) 100% sure I noticed the prepend issue with PF to… but is you say and test that it works, downvote removed – Kukeltje Jan 03 '16 at 08:37
  • Hmmmm I can't unless the answer is edited… weird – Kukeltje Jan 03 '16 at 08:38
  • Thanks for looking into this again. – Jens Piegsa Jan 03 '16 at 08:46