- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
doesn't seem to have any effect-6ren"> doesn't seem to have any effect-我有以下选择一个菜单。但区分大小写在其中不起作用。当我按小 a 或大写 A 时,它总是显示小 a(以先出现者为准)。 -6ren">
doesn't seem to have any effect
我有以下选择一个菜单。但区分大小写在其中不起作用。当我按小 a 或大写 A 时,它总是显示小 a(以先出现者为准)。
<p:selectOneMenu id="tempSelect" caseSensitive="true">
<f:selectItem itemLabel="0" itemValue="0"/>
<f:selectItem itemLabel="a" itemValue="a"/>
<f:selectItem itemLabel="A" itemValue="A"/>
<f:selectItem itemLabel="b" itemValue="b"/>
</p:selectOneMenu>
我的 primefaces 版本是 5.2。
当选择框获得焦点时。我按字母“a”或按大写字母“A”,在这两种情况下,它仅在框中显示“a”(因为它出现在列表中的第一个)。这是实际行为。
我的预期行为是,当我按“a”时,它会在框中放入“a”,而当我按“A”时,它会在框中放入“A”。
我应该为此做什么?
最佳答案
Primefaces 5.2 documentation (第 430 页)关于 CaseSensitive 选项的说明:
Defines if filtering would be case sensitive.
因此,此选项仅在您使用 filter="true"时适用,并且仅适用于您在过滤框中键入的值。
当您关注 SelectOneMenu 控件并输入值时,搜索将始终不区分大小写,如 source code of Primefaces (line 848) 中所示。 。请注意,在比较之前,文本以小写形式放置。
return $(this).text().toLowerCase().indexOf(text.toLowerCase()) === 0;
<小时/>
解决此问题的一种方法(不是很优雅)是覆盖负责此过滤器的 Primefaces 函数。请记住,在这种情况下,同一页面中的其他 SelectOneMenu 控件也将区分大小写。
所以第 848 行会变成这样:
return $(this).text().indexOf(text) === 0;
可能应该考虑的另一个细节(如果您确实想覆盖该函数)是 line 842 of source code 上的细节。 ,Primefaces 会丢弃所有具有 Shift 键的条目。
metaKey = e.metaKey||e.ctrlKey||e.shiftKey;
因此,这一行也应该像下面这样更改,以便于输入大写字母:
metaKey = e.metaKey||e.ctrlKey;
因此,考虑到这两个更改,以及 final version of Primefaces 5.2 (minified) ,解决方案是在 SelectOneMenu 之后的某个位置添加以下代码。
<script>
PrimeFaces.widget.SelectOneMenu.prototype.bindKeyEvents = function() {
var a = this;
this.focusInput.on("keydown.ui-selectonemenu", function(d) {
var c = $.ui.keyCode, b = d.which;
switch (b) {
case c.UP:
case c.LEFT:
a.highlightPrev(d);
break;
case c.DOWN:
case c.RIGHT:
a.highlightNext(d);
break;
case c.ENTER:
case c.NUMPAD_ENTER:
a.handleEnterKey(d);
break;
case c.TAB:
a.handleTabKey();
break;
case c.ESCAPE:
a.handleEscapeKey(d);
break
}
}).on(
"keyup.ui-selectonemenu",
function(g) {
var f = $.ui.keyCode, d = g.which;
switch (d) {
case f.UP:
case f.LEFT:
case f.DOWN:
case f.RIGHT:
case f.ENTER:
case f.NUMPAD_ENTER:
case f.TAB:
case f.ESCAPE:
case f.SPACE:
case f.HOME:
case f.PAGE_DOWN:
case f.PAGE_UP:
case f.END:
case f.DELETE:
case 16:
case 17:
case 18:
case 224:
break;
default:
var i = $(this).val(), c = null, h = g.metaKey
|| g.ctrlKey;
if (!h) {
clearTimeout(a.searchTimer);
c = a.options.filter(function() {
return $(this).text()
.indexOf(i) === 0
});
if (c.length) {
var b = a.items.eq(c.index());
if (a.panel.is(":hidden")) {
a.selectItem(b)
} else {
a.highlightItem(b);
PrimeFaces.scrollInView(
a.itemsWrapper, b)
}
}
a.searchTimer = setTimeout(function() {
a.focusInput.val("")
}, 1000)
}
break
}
})
}
</script>
要进行测试,请记住有 a timer of 1 second在每次击键之间清除已输入字母的缓存并开始一个新单词。
关于jsf - <p :selectOneMenu caseSensitive ="true"> doesn't seem to have any effect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32477281/
关于strcat函数。 while (*p) p++; 和 while (*++p) ; 两者都有效,但是 while (*p++) ; 不起作用。我认为 first 和 th
" in HTML?(HTML中的““是什么
?)
下面例子中的第一行代码是什么。我看到一个YouTuber在写下面的代码,它显示了一个设计在csswar Challenges中。我也尝试了一下,它很管用。但我以前从未在任何HTML教程上看到过它,我在
vs.
是不间断空格,表示没有换行的空白处。 如果我用 我在两个段落之间有一个空格(更大的间隔)。如果我使用 我在两个段落之间只有一个新行(没有中断)。为什么? 最佳答案 在 HTML 中
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 9
我对编程还很陌生,只是想知道为什么这段代码: for ( ; *p; ++p) *p = tolower(*p); 当 p 指向一个字符串时,可以降低 c 中字符串的大小写吗? 最佳答案 一般来说,这
代码 int n = 25; int *p = &n; printf("%x\n %d\n %x\n", p, p[0], p[1]); 返回: \ 当然我永远不会这样做,但在 K&R 中声明
所以,我想创建一个简单的程序,返回有关连续素数的计算结果。首先,我创建一个包含所有这些素数的列表,然后尝试计算结果,但这给了我一个超出范围的索引。有人可以帮助我吗?我的程序: primes = []
这个问题在这里已经有了答案: With arrays, why is it the case that a[5] == 5[a]? (20 个答案) 关闭 9 年前。 我想知道 C/C++ 中以下四
我仍在努力理解 *p、&p 和 p 之间的区别。根据我的理解,* 可以被认为是“指向的值”,而 & 可以被认为是“地址”。换句话说,* 保存值,而 & 保存地址。如果这是真的,那么 *p 和 p 之间
你是吗? [xxxrecipientFirstNamexxx]
和你是吗? {recipientFirstName}
需要更换 你是吗? [xxxrecipientFirstNamexxx] 和 你是吗? {recipientFirstName} 。我尝试使用边界匹配器。但结果并不符合预期。我尝试使用下面的代码 "A
我想按 IsTop 属性升序排序对象,然后按 JobId 属性降序排序: query = query.OrderBy(p => p.IsTop).ThenOrderByDescending(p =
在我尝试使用 Apache POI 进行转换的 Excel 文件中,我有一个单元格的数值为 -3.97819466831428,自定义格式为“0.0 p.p.;(0.0 p.p.)”。因此,在 Exc
我想创建一个扩展方法,允许我调用 ToSerializableDictionary(p => p.ID)而不是 .ToDictionary(p => p.ID)在以下 LINQ 上下文中。虽然我不确定
在下面的 HTML 代码上运行此 jQuery 代码会返回不同的结果,我认为它们应该返回相同的值。 jQuery 代码: var counter = 0; $("p").each(function()
在下面的代码片段中,符号 *p 等同于 p[0],*(p + 1) 等同于p[1],依此类推。 int* p = new int[3] { 1, 2, 3}; cout << *p << ' ' <<
这个问题在这里已经有了答案: What will happen when I call a member function on a NULL object pointer? [duplicate]
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Undefined Behavior and Sequence Points 按照标准中的定义,E1 +=
" in HTML?(在HTML中“
以下示例中的第一行代码是什么。我看到一个youtube用户写下面的代码,它显示在cssbattle挑战的设计。我也试过,它的作品。但我从来没有见过它在任何HTML教程之前,我在谷歌上搜索它,但它只显示
每当我收到来自 MS outlook 的电子邮件时,我都会收到此标记 & nbsp ; (没有空格)哪个显示为?在 <>. 当我将其更改为 ISO-8859-1 时,浏览器页面字符集编码为 UTF-8
p1
TESTp2
代码: from bs4 import BeautifulSoup soup = BeautifulSoup('p1TESTp2') print soup.div() 结果: [p1, p2] 为什么
我是一名优秀的程序员,十分优秀!