문제

i just don't get it...

Why p:commandLink not working? The page is refreshing but with the same amount of data in table. I'm supposing that controller is okay. Take a look.\

View:

    <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>
        <ui:composition template="./Template.xhtml">
            <ui:define name="content" >
                <f:view>
                    <h:form style="padding: 5px">
                        <p:dataTable id="dataTable2" var="item" value="#{warningsController.warns}">
                            <p:column rendered="#{loginController.admin}">
                                <f:facet name="header">
                                    <h:outputText value="Administracja" />
                                </f:facet>
                                <h:form>
                                    <p:commandLink id="Remove" value="Remove" action="#{warningsController.remove(item.id)}" ajax="false" />
                                </h:form>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </f:view>
            </ui:define>
        </ui:composition>

    </body>
</html>

and controller:

public String remove(long a){
    //System.out.println(a);
    pf.remove(pf.find(a));
    return "Listsev.xhtml";
}
도움이 되었습니까?

해결책

You have multiple h:forms cascaded/nested, that's invalid html. Unknown/wanted side effects can/may occur, maybe like you are experiencing right now. Get right if that inner h:form and try again.

In your remove method, pf is the list which you return by calling #{warningsController.warns}?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top