找不到属性 - JSF无法识别第二个字段?

时间:2016-09-18 21:01:32

标签: java jsf java-ee

我遇到了奇怪的问题,我不知道为什么会这样,我得到这样的课程:

@ManagedBean(name = "clientBean")
@SessionScoped
public class ClientBean implements Serializable {

private static final long serialVersionUID = 1L;

private ClientDao clientDao = new ClientDao();

private SearchService searchService = new SearchService();

private String tags;

private Client client = new Client();

private Order order = new Order();

我有.xhtml的一部分:

       <div class="form-group">
        <label style="padding-top: 0px" class="col-sm-3 control-label">Tytuł zamówienia</label>
            <div class="col-sm-9">
                <h:inputText type="text"
                        value="#{clientBean.order.title}"
                        class="form-control" />
                        </div>
                    </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">Status</label>
                  <div class="col-sm-9">
                   <h:inputText type="text" value="PRZETWARZANIE"
                        class="form-control" disabled="true" />
                  </div>
            </div>

问题是......为什么我无法设置值order.titleclient.name和Client类中的其他字段没有问题,但是当我尝试使用order的属性设置表单字段并进入此视图时,会出现此异常(我得到了所有的getter和setter):

SEVERE: Error Rendering View[/clients.xhtml]
javax.el.PropertyNotFoundException: /clientRegistration.xhtml @112,67  value="#{clientBean.order.title}": Property 'order' not found on type  com.firanycrm.controller.ClientBean
at  com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
at javax.faces.component.UIInput.getValue(UIInput.java:291)

1 个答案:

答案 0 :(得分:0)

要让JSF获取/设置您的属性,您需要在ClientBean类及其引用的类OrderClient等中为所有内容设置getter和setter。确保您拥有所有那些getter和setter,如果您使用像Eclipse这样的IDE(右键单击&gt; source&gt;生成getter和setter),我建议只生成它们。