简体   繁体   中英

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

I'm doing some examples about Spring Framework and Primefaces but my button does not call to simple printf function in my view layer. How can i call my function and print some string on console ?

This is my xhtml part:

<h:form id="jobForm">

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

</h:form>

This is my JobView.java file:

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 "";
    }

}

My problem was because of Spring Security dependency in pom.xml. I deleted and it solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM