问题标签 [selectmanymenu]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
663 浏览

jsf - 抛出 ELException:类 'java.lang.String' 没有属性 'foo'

我正在尝试以selectManyMenu高级模式实现primefaces,如展示中所示,但无法使其工作。

它非常适合selectOneMenu

这是我的 selectOneMenu 代码:

对于 selectManyMenu

我收到一个错误value="#{pa.name}": The class 'java.lang.String' does not have the property 'name'.

我已经加倍检查,我的equal()hashcode()toString()方法。我认为如果这些方法有问题,那么selectOneMenu也不应该奏效。

请注意,当我删除var='pa'and时<column ...>,它可以完美运行。

0 投票
2 回答
235 浏览

arrays - 为什么 UISelectMany 不返回泛型属性的集合?

我有一个包含一个<h:selectManyMenu>元素的 JSF 页面。value 属性指向在子类中定义为 type 的通用对象ArrayList<String>。根据java文档,UISelectMany应该从转换中返回它的值作为Collection这个具体类型。但它作为String[]数组返回。我错过了什么?

0 投票
0 回答
28 浏览

jsf - selectManyMenu 转换器基础知识

我正在尝试使 selectManyMenu 工作,但我在正确编写转换器时遇到问题。这是我第一次需要编写转换器,所以事情对我来说不是那么清楚。我已经阅读了几个地方,我不应该在转换器中对数据库进行任何调用,但是除了调用 DB 之外,如何在 getAsObject 方法中获取某些 ID 的对象?

}

重要的:

页面加载时,我的 selectManyMenu 充满了记录,但我看不到它的名称,只有复选框和空格,而不是记录名称(设备)。但是,如果我尝试将一些字符放在搜索过滤器中,即使我只看到复选框而不是名称,它也会起作用。我添加了 itemDescription="#{record.name}" ,当我将鼠标指针放在某个记录上时,会显示 itemDescription。因此,显然组件可以访问所有记录,但它的名称没有显示出来。您可以在以下位置查看屏幕截图:http ://i57.tinypic.com/2wpm2ok.png(“Autoklav”是不想出现在列表中的记录名称,但它显示为描述)。这不是css问题,我检查了:)

这是我的 selectManyMenu:

第二个问题是将字符串转换为对象,我不确定我必须做什么 - 是否调用 DB?目前,无论我尝试什么,我都会遇到错误,从 String (id?) 获取 Object 的正确方法是什么?

我按照http://www.primefaces.org/showcase/ui/input/manyMenu.xhtml上的说明进行操作,但不确定我做错了什么以及为什么我至少不能显示记录名称(getAsString 真的很简单,它应该工作)

有没有人有一些建议或已经有 selectManyMenu 的转换器?如果您需要更多信息,我很乐意为您提供。

谢谢!

0 投票
1 回答
1279 浏览

jsf - p:selectManyMenu 和 @FacesConverter(forClass = Clazz.class)

如果有人可能想将示例付诸实践,CSS 将保持不变。它将显示三种基本颜色 (RGB),并在它们前面带有复选框,如下所示。

在此处输入图像描述

托管bean:

如果converter="#{colourConverter}"从 中删除该属性<p:selectManyMenu>,则即使转换器用 装饰,它也会导致java.lang.ClassCastException在方法中抛出a 。action()@FacesConverter(forClass = Colour.class)

看来这是泛型类型橡皮擦问题(泛型类型参数 的List<Colour>在运行时被删除,因此它变成了 untyped List)。

Colour[]然后应该可以工作,但action()在尝试时未调用该方法本身。

它需要明确提及转换器的确切原因是什么?


额外的 :

转换器:

List<Colour>维护的应用程序范围的 bean 。

领域模型类:

0 投票
0 回答
618 浏览

jsf - p:selectManyMenu 取消选择确认

当我从多选 p:selectManyMenu 中取消选择一个项目时,我尝试获得一个确认对话框。

现在,如果取消选择某个项目(复选框更改为未选中),我想显示一个确认对话框。

我尝试使用 ajax 事件,如“取消选择”、“取消选择”、“rowUnselect”.. 有什么想法吗?

0 投票
1 回答
1356 浏览

arrays - ui:repeat 中的 UISelectMany 导致 java.lang.ClassCastException: [Ljava.lang.Object; 不能转换为 java.util.List

我已经使用了HashMap将复选框列表绑定到Map<String, Boolean>成功的方法。这很好,因为它允许您拥有动态数量的复选框。

我正在尝试将其扩展到selectManyMenu. 由于它们是 selectMany,我希望能够绑定到Map<String, List<MyObject>>. 我有一个示例,我可以将单个绑定selectManyMenu到 aList<MyObject>并且一切正常,但是当我将动态数量的 selectManyMenus 放入 aui:repeat并尝试绑定到地图时,我最终得到了奇怪的结果。值已正确存储在映射中,由调试器验证并调用toString(),但运行时认为映射的值是类型Object而不是类型,List<MyObject>并在我尝试访问映射的键时抛出 ClassCastExceptions。

我猜它与 JSF 如何确定绑定目标的运行时类型有关,并且由于我绑定到 a 中的值Map,它不知道从值类型参数中获取类型地图。除了可能修补 Mojarra 之外,是否有任何解决方法?

一般来说,我怎样才能拥有一个动态数量的 selectManyMenus 页面?当然没有使用 Primefaces 的<p:solveThisProblemForMe>组件。(说真的,由于我无法控制的因素,Primefaces 在这里不是一个选择。)

List<T> 上的 UISelectMany问题导致 java.lang.ClassCastException: java.lang.String cannot be cast to T有一些我不知道的好信息,但我仍然遇到这个 SSCE 的问题:

JSF:

转换器:

支持豆:

ItemStore 只包含一个 HashMap 和委托方法来通过它们的 ID 字段访问 Items。

物品:

项列表验证器:

错误:

Stacktrace 被剪断,但发生在这一行:

我在这里想念什么?

0 投票
0 回答
1284 浏览

jsf - @NotEmpty List validation

I have a JSF component which is mapped on a List in the corresponding bean. As I want the mapped field to contain at least one value when the form is submitted, this field is annoted @NotEmpty.

Bean :

Each time the user select something on my component I want the selection to be immediatly mapped in the bean, so I add an ajax behaviour to the component (Here the component is a p:selectManyMenu but the issue seems to be present with any component mapped to a List) :

XHTML :

My issue happens in the following situation :

  1. The user selects one or several choices (Ctrl + click here).
  2. He unselects every choices he just selected.
  3. He submits the form.
  4. We can see in the result dataList that the last unselected value is still in the bean.

My understanding of the situation is that when the user unselects the last value, the validation fails because of the @NotEmpty annotation on the field (as confirmed by the p:message validation failure message). As a consequence the setter is not called and the last unselected value remains in the bean.

How can I, in a proper way, allow the user to unselect every items without validation failures, and run the validator on this field only when the form is submitted ?

0 投票
0 回答
524 浏览

primefaces - 如何在 p:selectmanymenu 下拉列表中的复选框和标签值之间添加空格

我需要在复选框和下拉列表项之间有一个空格,其中下拉项是从 BackingBean 动态检索的。

我试过了

我还尝试从支持 bean 中获取一个 emptyString 变量并将其连接起来。

0 投票
1 回答
676 浏览

jsf - javax.faces.FacesException:值必须是数组或集合

我收到错误消息:

javax.faces.FacesException:'frmrapport:type' 的值必须是数组或集合

来自 XHTML 文件:

来自 Java bean:

问题是 bean 是 a List,我无法将列表转换为 a String[]

0 投票
1 回答
469 浏览

jsf - Primefaces selectManyMenu - 从对象加载列表

所以我的场景是这样的:

我加载了一个人,它有一个整数值列表,代表该人观看过的所有视频。

例如,如果人 12345 观看了三个视频,它将在列表中表示为[4012, 2001292, 50201]

该列表可以是 0..x,并由 Primefaces 中的 selectManyMenu 表示。

当我从数据库加载人员并尝试编辑人员时,而不是在 selectManyMenu 中查看该人员查看过的每个视频,它显示的是第一个视频,仅此而已。它显示 0 或 1。不是很多。

代码:

有任何想法吗...?