在Liferay中未调用commandButton操作方法

时间:2015-05-30 15:10:30

标签: jsf liferay portlet

我有以下portlet view.xhtml

 <?xml version="1.0"?>
    <f:view xmlns="http://www.w3.org/1999/xhtml"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">

            <h:body>

                <h:form>
                    <h:commandButton value="TESTButton" action="#{navigationViewBean.submit}" />
                    <h:outputText value="TESTGetter: #{navigationViewBean.testField}" />
                </h:form>
            </h:body>
    </f:view>

这个托管bean:

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "navigationViewBean")
@RequestScoped
public class NavigationViewBean {
    private String testField;
    public boolean lol = false;

    public void submit() {
        System.out.print("TEST BUTTON INVOKED");
    }

    public String getTestField() {
        System.out.print("TEST GETTER INVOKEDx");
        return testField;
    }

    public void setTestField(String testField) {
        this.testField = testField;
    }

}

我唯一要做的就是调用一个方法来打印一些东西到我的控制台。问题在于,无论我做什么,都不会调用action方法。正确调用getter方法。

我做错了什么?

1 个答案:

答案 0 :(得分:6)

我不确定原因,但在将此行添加到我的liferay-portlet.xml后,修复了它。

<requires-namespaced-parameters>false</requires-namespaced-parameters>

这里整个街区:

<portlet>
        <portlet-name>Test1</portlet-name>
        <icon>/icon.png</icon>
        <requires-namespaced-parameters>false</requires-namespaced-parameters>
        <header-portlet-css>/css/main.css</header-portlet-css>
</portlet>
相关问题