次のjsfページを作成しました。マネージド Bean で入力を評価したいのですが、値を取得できません。
commandLink を押しても、値が得られません。commandButton を使用すると動作します:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="../templates/common.xhtml">
<ui:define name="pageTitle">Test</ui:define>
<ui:define name="pageHeader">Test</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green"
layout="table" />
</h:panelGroup>
<h:form>
<h:outputLabel value="#{bundle.SearchAdressLabel_name}"
for="axname" />
<h:inputText id="axname"
value="#tbaxController.name}"
title="#{bundle.SearchAdressTitle_name}" />
</h:panelGrid>
<br />
<br />
<h:commandButton id="submit" value="#{bundle.SearchAdressLabel_cmdsearch}" action="#{tbaxController.prepareList}">
</h:commandButton>
<h:commandLink action="#{tbaxController.prepareList}"
value="#{bundle.SearchAdressLabel_cmdsearch}" immediate="true" />
<br />
<br />
<h:commandLink value="#{bundle.SearchAdressLabel_cmdclear}"
type="reset" />
</h:form>
</ui:define>
</ui:composition>
</html>
これが私のMBの一部です:
@ManagedBean(name = "tbaxController")
@SessionScoped
public class tbaxController implements Serializable {
private static final long serialVersionUID = 1L;
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
.getLogger(tbaxController.class);
private Tbax current;
private DataModel items = null;
@EJB
private TbaxFacade ejbFacade;
private PaginationHelper pagination;
private int selectedItemIndex;
private String name;
public tbaxController() {
}
public String getname() {
// Get the field
return searchAxart;
}
public void setname(String oname) {
// Set the field this.searchAxart
this.name = oname.trim();
}
...
public String prepareList() {
logger.info("prepareList:" + name); **//null with commandLink!
recreateModel();
return "ADList";
}
...
私の prepareList メソッドが commandLink で値を取得しないのはなぜですか?