ページからコントローラー メソッドを使用しようとすると問題が発生します。
action と actionListener を試してみましたが、これら 2 つを ajax="true" と immediate="true" と混合したので、これ以上の可能性はありません。
最初はbeanを取っていないと思っていましたが、render test属性を持っています。
これらのメソッドを呼び出すにはどうすればよいですか?
p:url を使用できることはわかっていますが、代わりに commandButton を使用したいと思います。
私のコントローラー:
@Controller
@RequestMapping("/orderService")
@ManagedBean(name="orderServiceController")
@SessionScoped
public class OrderServiceController implements Serializable{
private static final long serialVersionUID = -8694892885365853014L;
@Autowired
private OrderService orderService;
@Autowired
private OrderContainer container;
public String test = "test";
public String getTest() {
return test;
}
@RequestMapping("/waiterInformed/{tableNumber}")
public String waiterInformed(@PathVariable Integer tableNumber ){
log.info("##>> OrderServiceController waiterInformed INI on table " +
tableNumber + "<<");
orderService.waiterInforme(tableNumber);
return "redirect:/orderService/";
}
(...)
}
顔-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>es</supported-locale>
</locale-config>
<resource-bundle>
<base-name>messages.messages</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
そして最後に、「order.xhtml」が私のapp-configにマッピングされました
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:head>
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
</script>
</h:head>
<h:body onload="JavaScript:timedRefresh(15000);"> <!-- Reload every 15 secs -->
<h2>#{msg['order.label.title']}</h2>
<h3>List</h3>
<!-NOT WORKING (log is not showing any message -->
<p:commandButton value="test" action="#{orderServiceController.waiterCalled}">
<f:param name="tableNumber" value="1"/>
</p:commandButton>
<p:commandButton value="test" action="#{orderServiceController.waiterCalled}">
<f:attribute name="tableNumber" value="1"/>
</p:commandButton>
<!-WORKING-->
<h:outputText value="#{orderServiceController.test}"/>
(...)
</h:body>
</html>