[英]Simplest JSF 2.0 application will not work
I've never had such a problem getting the simplest stuff to work in Java EE 6. I have an extremely basic project. 使最简单的东西在Java EE 6中工作从未遇到过这样的问题。我有一个非常基础的项目。 I've tried debugging.
我试过调试。 Etc. I don't know what to do.
等等,我不知道该怎么办。
Here is my bean. 这是我的豆子。
@Named(value = "contactsBean")
@SessionScoped
public class ContactsBean implements Serializable {
@EJB
ContactsFacade contactsEJB;
private List<Contacts> contacts = new ArrayList<Contacts>();
public ContactsBean() {
}
public String next() {
contacts = contactsEJB.findAll();
return "index";
}
/**
* @return the contacts
*/
public List<Contacts> getContacts() {
return contacts;
}
/**
* @param contacts the contacts to set
*/
public void setContacts(List<Contacts> contacts) {
this.contacts = contacts;
}
}
Ok. 好。 Pretty basic.
很基本。
Here is my xhtml page. 这是我的xhtml页面。
<ui:define name="content">
<h:form>
<h:dataTable value="#{contactsBean.contacts}" var="contacts">
<h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{contacts.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Street"/>
</f:facet>
<h:outputText value="#{contacts.street}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="City"/>
</f:facet>
<h:outputText value="#{contacts.city}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="State"/>
</f:facet>
<h:outputText value="#{contacts.state}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Zip"/>
</f:facet>
<h:outputText value="#{contacts.zip}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Country"/>
</f:facet>
<h:outputText value="#{contacts.country}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Sent?"/>
</f:facet>
<h:selectBooleanCheckbox value="#{contacts.sent}" />
</h:column>
</h:dataTable>
<h:commandButton value="next >" action="#{contactsBean.next}"/>
</h:form>
</ui:define>
Ok when I hit the next button my list should populate. 好的,当我点击下一步按钮时,我的列表应该会填充。 At least it always did in Java EE 5 stuff.
至少在Java EE 5中它总是如此。 I'm not sure what I'm doing wrong.
我不确定自己在做什么错。 I was trying to do a simple paginator but even that wouldn't work.
我试图做一个简单的分页器,但即使那样也行不通。 The model never gets updated.
该模型永远不会更新。
What in the world is going on. 世界上正在发生什么。 I tried it without an EJB and it didn't work either.
我在没有EJB的情况下进行了尝试,但也无法正常工作。
I found out the reason. 我找出原因了。
There are to different packages with SessionScoped annotations. 有带有SessionScoped批注的不同软件包。
javax.enterprise.context.SessionScoped and javax.faces.context.SessionScoped. javax.enterprise.context.SessionScoped和javax.faces.context.SessionScoped。
Since I'm using @Named(value = "contactsBean") injection I need to use javax.enterprise. 由于我正在使用@Named(value =“ contactsBean”)注入,因此我需要使用javax.enterprise。 @ManagedBean(name = "contactsBean") goes with javax.faces.context.
@ManagedBean(name =“ contactsBean”)与javax.faces.context一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.