开发者

ActionListener and update DataGrid from a button within a panel that is inside the datagrid using ajax doesn't work

开发者 https://www.devze.com 2023-04-12 06:58 出处:网络
I have this xhtml code: <p:dataGrid id=\"dgData\" columns=\"1\" rows=\"100\" value=\"#{myStickiesController.items}\"

I have this xhtml code:

<p:dataGrid id="dgData"
    columns="1"
    rows="100"
    value="#{myStickiesController.items}"
    var="sticky">
    <p:panel header="From :#{sticky.users.displayName}" rendered="#{eventstickiesController.eventSticky}" binding="#{eventstickiesController.eventPanel}">
        <f:attribute name="stickyId" value="#{sticky.stickyID}" ></f:attribute>
        <h:panelGrid columns="2">
            <p:graphicImage value="#{imageStreamer.fileContent}" style="width:50px; height: 50px" alt="No Profile Image">
                <f:param id="uid" name="uid" value="#{sticky.users.userID}" />
            </p:graphicImage>
            <h:outputLabel value="Event Info : #{eventstickiesController.content}" binding="#{eventstickiesController.outputLabel}">
                <f:attribute name="stickyId" value="#{sticky.stickyID}" ></f:attribute>
            </h:outputLabel>
        </h:panelGrid>
        <f:facet name="footer">
            <p:commandButton image="/images/buttons/Delete.gif"
                             actionListener="#{myStickiesController.deleteSticky}"
                             action="#{snippetsStickyEditorLinkerBean.updateSnippetLink}"
                             update="dgData" >
                <f:attribute name="stickyId" value="#{sticky.stickyID}" ></f:attribute>
       开发者_开发问答         <f:param  name="pageViewId" value="Default"/>
            </p:commandButton>
        </f:facet>
    </p:panel>
</p:dataGrid>

the code of the actionListener class:

public class MyStickiesController {
public void deleteSticky(ActionEvent ae)
{
    Long sid = (Long)ae.getComponent().getAttributes().get("stickyId");
    Stickies s = ejbFacade.find(sid);
    List<Recipients> rl = s.getRecipientsList();
    DBConnectionProxyUser sbcpu = new DBConnectionProxyUser();
    Users currentUser = sbcpu.getConnectedUser(ejbUsersFacade);
    for (Recipients r:rl)
    {
        if (currentUser.getUserID()==r.getUsers().getUserID())
        {
            r.setDisplay(Boolean.FALSE);
        }
    }       
}
}

Now, if I put the command button that is inside the p:dataGrid, the dataGrid is updated and the actionListener works. If I put the button inside the dataGrid, the dataGrid is not updated and the actionListener doesn't work.

I tried wrapping thw whole thing with p:outputPanel, and the actionListener doesn't work.

The ActionEvent is javax.faces.event.ActionEvent I am using Mojarra 2.1.3 with primefaces 2.2.1, Glassfish 3.0.1 and Netbeans 6.9.1

Thanks in advance...


I managed to make it work...

The solution renders into 2 parts:

  1. I updated the Glassfish Mojarra Module to 2.1.3

  2. I added a p:remotecommamd and a p:outputpanel to be rendered in case the inner snippet is to be rendered. Other snippets are easy to be rendered.

I hope this one helps somebody...

0

精彩评论

暂无评论...
验证码 换一张
取 消