【发布时间】:2018-08-13 07:35:11
【问题描述】:
我正在尝试集成 spring 和 JSF(Primefaces)。我使用 @component 注释将 spring 控制器配置为组件以用作 JSF bean,但它没有调用命令按钮的操作方法。
XHTML 文件:
<h:form id="productForm" >
<h:panelGrid columns="1">
<p:outputLabel for="name" value="Name: " />
<p:inputText id="name" value="#{cust.customerForm.name}" />
<p:outputLabel for="address" value="address" />
<p:inputNumber id="address" value="#{cust.customerForm.address}" />
<p:outputLabel for="email" value="Email: " />
<p:inputNumber id="email" value="#{cust.customerForm.email}" />
<p:outputLabel for="mobile" value="Mobile: " />
<p:inputNumber id="mobile" value="#{cust.customerForm.mobile}" />
<p:commandButton value="Save" action="#{cust.save}" />
</h:panelGrid>
</h:form>
Spring 控制器用作 JSF Bean:
@Scope(value="session")
@Component(value = "cust")
@ELBeanName(value = "cust")
@Controller
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private CustomerRepository customerRepo;
private List<Customer> customerList;
private Customer customerForm;
public List<Customer> getCustomerList() {
return customerList;
}
public Customer getCustomerForm() {
return customerForm;
}
public void setCustomerForm(Customer customerForm) {
this.customerForm = customerForm;
}
public String save(){
System.out.println("save called:::::::::::");
return("Customer");
}
}
请帮助我找出我做错了什么。
【问题讨论】:
-
您是否尝试将问题的标题放在谷歌中? stackoverflow.com/questions/18387993/…
-
@Kukeltje 我正在使用spring托管bean,我需要通过commandbutton调用的方法是spring控制器方法....那么有什么方法可以调用spring托管bean的方法用作控制器以及来自 JSF commandButton..
-
你从副本中尝试了什么?
-
从副本中我尝试使用组件注释在 spring 中使用一个类作为 JSF 支持 bean...
标签: spring spring-boot jsf primefaces