为什么 commandbutton 动作不会在视图层调用功能?
Why commandbutton action does not call to function in view layer?
我正在做一些关于 Spring Framework 和 Primefaces 的例子,但是我的按钮没有调用视图层中的简单 printf 函数。我如何调用我的函数并在控制台上打印一些字符串?
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 "";
}
}
我的问题是因为 Spring pom.xml 中的安全依赖项。我删了就解决了
我正在做一些关于 Spring Framework 和 Primefaces 的例子,但是我的按钮没有调用视图层中的简单 printf 函数。我如何调用我的函数并在控制台上打印一些字符串?
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 "";
}
}
我的问题是因为 Spring pom.xml 中的安全依赖项。我删了就解决了