-1

I have many panelGrid's, I want to open a dialog when I click on panelGrid.

The problem is always selected the last panelGrid.

index.xhtml

<p:dataGrid var="object" value="#{vc.objects}" 
layout="grid" id="dataGridObject">
    <h:panelGrid columns="1" onclick="rc()">                                                                                                              
        <h:outputText value="#{object.name} " />                                                                                                       
        <p:remoteCommand name="rc" update="formX" 
oncomplete="PF('dlgDetails').show()" action="#{vc.updateSelectObject(object)}"/>
    </h:panelGrid>
</p:dataGrid>

ViewController.java

private Object selectObject;

public void updateSelectObject(Object object){
    setSelectObject(object);
}

public Object getSelectObject() {
    return selectObject;
}

public void setSelectObject(Object selectObject) {
    this.selectObject = selectObject;
}

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
forthewin
  • 9
  • 1
  • 7
  • Check your source. See how many javascript functions called `rc()` there are. – Kukeltje Jun 18 '20 at 16:04
  • 2
    Does this answer your question? [p:remoteCommand actionListener inside p:dataTable only works with last row](https://stackoverflow.com/questions/59162360/premotecommand-actionlistener-inside-pdatatable-only-works-with-last-row) – Kukeltje Jun 18 '20 at 16:09
  • Kukeltje, how??? I dont understand. – forthewin Jun 18 '20 at 16:25
  • See the duplicate, I meant the client-side html source, sorry – Kukeltje Jun 18 '20 at 16:34
  • My problem is with the dataGrid, not datatable... with datatable i can select row.. – forthewin Jun 18 '20 at 16:37
  • Problem is 1000% identical, solution is 1000% identical in the textual part before the suggestion not overly complicate things and use ajax. That is solution there since it is on an `h:inputText`. Nowhere in the other question, datatable selection is mentioned. Read the whole duplicate and try to unserstand it. Do as is stated (examining the html) instead of focussing on the datatable part. Think as a developer (And I changed the title of the duplicate to make it reflect the more generic issue) – Kukeltje Jun 18 '20 at 18:35
  • I keep saying it's not the same... My problem presist... – forthewin Jun 19 '20 at 09:45
  • I keep saying it is... The code you posted above 10000% (a zero is automatically added each time I have to state it ;-)) causes the same problem as in the duplicate.... Just stating it is not, without showing evidence, is not what developers do. Sure your problem persists, you did not change anything in the code or rather/better created a new question with improved code since this one just is a duplicate of the other one. Goodluck with your endeavours... – Kukeltje Jun 19 '20 at 09:50

1 Answers1

-1

Why don't you try another approach. In this case with dataGrid you can replace outputText and remoteCommand with commandButton and you can style your button to look just like a panel.

    <p:dataGrid var="object" value="#{vc.objects}" 
     layout="grid" id="dataGridObject" columns="1">
     <p:commandButton value="#{object.name}" 
     actionListener="#{vc.updateSelectObject(object)}" process="@this"
     update="formX" oncomplete="PF('dlgDetails').show()" />
    </p:dataGrid>
korbn
  • 52
  • 2