Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>your code does look pretty good already. How does the <code>CounterControler</code> internally work? (no source given) Alternatives to send the current object might be </p> <ul> <li>to give the object directly as the parameter (you need a fitting converter for that), </li> <li>give it as direct parameter (<code>action="#{AddPollContorler.removeAnswer(answer)}</code>, works from EL 2.2 on), or </li> <li>directly get the current object out of the given ActionEvent</li> </ul> <p>The last point would look like </p> <p>xhtml</p> <pre><code>&lt;h:commandLink action="#{AddPollContorler.removeAnswer}"&gt; &lt;h:graphicImage library="img" name="cross.png" /&gt; &lt;f:ajax render="answers" /&gt; &lt;/h:commandLink&gt; </code></pre> <p>managed bean</p> <pre><code>public void removeAnswer(ActionEvent ev) { Answer selectedItem = null; try { UIDataTable objHtmlDataTable = retrieveDataTable( (UIComponent)ev.getSource()); selectedItem = (Answer) objHtmlDataTable.getRowData(); answers.remove(answer); } catch (NullPointerException e) { // somehow couldn't find the element } } private static UIDataTable retrieveDataTable(UIComponent component) { if (component instanceof UIDataTable) { return (UIDataTable) component; } if (component.getParent() == null) { return null; } return retrieveDataTable(component.getParent()); } </code></pre> <p>I like that one because it takes most logic out of the frontend. Hope you get your rows cleaned with one of that tactics. </p> <p>Also, you only need to mention <code>answers</code> once in <code>&lt;f:ajax render="answers" /&gt;</code></p> <p><strong>EDIT:</strong> Even I don't know why - wrapping a <code>&lt;h:panelGroup layout="block" id=" answersWrapper"&gt;</code> around the <code>&lt;h:dataTable&gt;</code> and rendering that panelGroup worked for me.</p> <pre><code>&lt;h:form id="myForm"&gt; &lt;h:panelGroup id="answerWrapper" layout="block"&gt; &lt;rich:dataTable value="#{myTestBean.answers}" var="answer" id="answers"&gt; &lt;h:column &gt; &lt;h:outputText value="#{answer}"/&gt; &lt;h:commandButton id="button" action="#{myTestBean.doTheAction}"&gt; &lt;f:ajax render=":myForm:answerWrapper" /&gt; &lt;/h:commandButton&gt; &lt;/h:column&gt; &lt;/rich:dataTable&gt; &lt;/h:panelGroup&gt; &lt;/h:form&gt; </code></pre>
    singulars
    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.
    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