我有一个ap:selectOneMenu的问题,无论我做什么我都无法让JSF调用JPA实体上的setter.JSF验证失败,显示以下消息:
form:location:验证错误:值无效
我有这个工作在几个相同类型的其他类(即,连接表类),但不能为我的生活让这一个工作.
如果有人可以针对此类问题提出一些故障排除/调试技巧,我们将不胜感激.
使用日志语句我已经验证了以下内容:
Conveter将返回正确的,非null数值.setLocation(Location location)永远不会调用setter .这是我能做的最简单的例子,它根本不起作用:
<h:body>
<h:form id="form">
<p:messages id="messages" autoUpdate="true" />
<p:selectOneMenu id="location" value="#{locationStockList.selected.location}" converter="locationConverter">
<p:ajax event="change" update=":form:lblLocation"/>
<f:selectItems value="#{locationStockList.locationSelection}"/>
</p:selectOneMenu>
</h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)
转换器:
@FacesConverter(forClass=Location.class, value="locationConverter")
public class LocationConverter implements Converter, Serializable {
private static final Logger logger = Logger.getLogger(LocationConverter.class.getName());
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value.isEmpty())
return null;
try {
Long id = Long.parseLong(value);
Location location = ((LocationManagedBean) context.getApplication().getELResolver().getValue(context.getELContext(), null, "location")).find(id);
logger.log(Level.SEVERE, …Run Code Online (Sandbox Code Playgroud) 我正在使用JSF 2.0创建Web应用程序,我将分配用户来查看项目.为此我有两个清单.具有未分配该项目的用户的第一个列表和列表B具有已分配该项目的用户.我们可以交换数据.
我的代码是
<t:selectManyListbox id="sourceCars" style="width: 40%;"
value="#{PersonalInformationDataBean.listOfUsers}" size="10">
<t:selectItems value="#{PersonalInformationDataBean.showAllMyRemData()}" var="t"
itemLabel="#{t.title}" itemValue="#{t.status}"/>
</t:selectManyListbox>
<span>
<input type="button" value=" >> " id="dbleMeRight"/>
<input type="button" value=" << " id="dbleMeLeft"/>
</span>
<t:selectManyListbox id="targetCars" style="width: 40%;"
value="#{PersonalInformationDataBean.listOfUsers}" size="10">
<t:selectItems value="#{PersonalInformationDataBean.showAllMyData()}" var="n"
itemLabel="#{n.title}" itemValue="#{n.status}"/>
</t:selectManyListbox>
<h:commandButton value="Save Edited Project Info." action="#{PersonalInformationDataBean.editPatentData(MyLogin.loginname)}" />
Run Code Online (Sandbox Code Playgroud)
其中t是xmlns:t="http://myfaces.apache.org/tomahawk".
PersonalInformationDataBean.java
private List<String> listOfUsers = new ArrayList<String>();
private List<String> listOfUsers002 = new ArrayList<String>();
private List<CommonBean01> listOfListUsers = new ArrayList<CommonBean01>();
private List<CommonBean01> listOfListUsers002 = new ArrayList<CommonBean01>();
// above getter and …Run Code Online (Sandbox Code Playgroud)