簡體   English   中英

為什么commandbutton動作不會調用視圖層中的函數?

[英]Why commandbutton action does not call to function in view layer?

我正在做一些關於Spring Framework和Primefaces的例子,但是我的按鈕在我的視圖層中沒有調用簡單的printf函數。 如何調用我的函數並在控制台上打印一些字符串?

這是我的xhtml部分:

<h:form id="jobForm">

<p:commandButton id="Print" value="Submit" 
actionListener="#{jobView.myFunc}" />

</h:form>

這是我的JobView.java文件:

import javax.annotation.PostConstruct;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.myjob.model.JobModel;
import com.myjob.utility.Utility;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Component(value = "jobView")
@Scope(value = "view")
public class JobView implements Serializable {

    private static final long serialVersionUID = 6901036085773777713L;

    private List<JobModel> jobs;
    private HashMap<String, String> cbLevels;
    private HashMap<String, String> selectedLevels;
    private String selectedLevel;

    public void startDataTable() {

        jobs = Utility.getResponse("http://localhost:8080/jobs/all");

        cbLevels = new HashMap<String, String>();
        //Filling hashmap here.
        cbLevels.put("Working", "Working");
        cbLevels.put("Graduated", "Graduated");
        cbLevels.put("Student", "Student");

    }

    @PostConstruct
    public void init() {

        startDataTable();

    }

        //My print function which i want to call
    public String myFunc(){

        System.out.println("Hello !");

        return "";
    }

}

我的問題是因為pom.xml中的Spring Security依賴性。 我刪除了,它解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM