感谢这里的一些很棒的文章,我已经能够<h:selectOneMenu />使用包含对象的selectItems 构建一个.在提供自定义FacesConverter并修复缺少的equals()/ hashcode()方法之后,我可以使用它来更改辅助bean的属性并将其写入数据库.
唯一奇怪的是 - 元素的所有 HTML 元素都是!换句话说:不反映绑定属性的当前值!<option /><select />checked="checked"<h:selectOneMenu />
细节:
Store.java
@Entity
public class Store {
private Long id;
private String name;
@ManyToOne
private Category category;
// getters, setters, equals, hashcode
}
Run Code Online (Sandbox Code Playgroud)
Category.java
@Entity
public class Category {
private Long id;
private String name;
// getters, setters, equals, hashcode
}
Run Code Online (Sandbox Code Playgroud)
editStore.xhtml
<h:form>
....
<h:selectOneMenu value="#{backingBean.store.category}" id="category">
<f:selectItems value="#{backingBean.categorySelectItems}" />
</h:selectOneMenu>
....
</h:form>
Run Code Online (Sandbox Code Playgroud)
BackingBean.java
public class BackingBean {
private Store store; …Run Code Online (Sandbox Code Playgroud) 我有:-
IEnumerable<IEnumerable<T>> items;
Run Code Online (Sandbox Code Playgroud)
我想创造: -
IEnumerable<IEnumerable<T>> results;
Run Code Online (Sandbox Code Playgroud)
其中"结果"中的第一项是"项目"的每个IEnumebles的第一项的IEnumerable,"结果"中的第二项是每个"项目"的第二项的IEnumerable等.
IEnumerables不一定是相同的长度.如果项目中的某些IEnumerables在特定索引中没有元素,那么我希望结果中匹配的IEnumerable中包含更少的项目.
例如:-
items = { "1", "2", "3", "4" } , { "a", "b", "c" };
results = { "1", "a" } , { "2", "b" }, { "3", "c" }, { "4" };
Run Code Online (Sandbox Code Playgroud)
编辑:另一个例子(评论中要求): -
items = { "1", "2", "3", "4" } , { "a", "b", "c" }, { "p", "q", "r", "s", "t" };
results = { "1", "a", "p" } , { "2", "b", "q" }, { "3", …Run Code Online (Sandbox Code Playgroud) 说我有一个这样的下拉列表:
<select id="MyDropDown">
<option value="0">Google</option>
<option value="1">Bing</option>
<option value="2">Yahoo</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我想根据选项文本设置选定的值,而不是使用javascript设置值.我该怎么做呢?例如,使用c#我可以执行类似下面示例的操作,并选择"Google"选项.
ListItem mt = MyDropDown.Items.FindByText("Google");
if (mt != null)
{
mt.Selected = true;
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
我正在rails应用程序中创建国际化的语言环境文件,并且有一个我想要翻译的URL,例如包含标签
html.erb
<%= t(foo.bar.xxxx)%>
yml文件
foo:bar:xxxx:"xxxx"
结果
< a href ="/ info/index.html"> xxxx </ a>
这打破了我的链接.我没有红宝石部分,所以不应该这样吗?或者我应该在yml文件中没有html标签?
Rails版本是3.0.1 Ruby版本是1.8.7 p249
我正在尝试解决Web应用程序的注销功能.当您登录时,该应用程序会为其域设置多个Cookie.这是当前的注销程序:
session_destroy()并循环遍历域的所有cookie,并将它们设置为过去(请参阅下面的代码)在此过程结束时,所有其他cookie都未设置,但PHPSESSIDcookie仍然存在,具有相同的值,并且仍设置为在会话结束时到期.
我在这里错过了什么?
这是我上面提到的注销功能:
function log_out_current_user() {
// Destroy the session
if (isset($_SESSION)) {
session_destroy();
}
// Expire all of the user's cookies for this domain:
// give them a blank value and set them to expire
// in the past
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
// Explicitly unset this cookie - …Run Code Online (Sandbox Code Playgroud) 我已经开通了一个关于社交网络的大型网络项目.我的项目获得了30多个投标,许多提供商推荐使用php,即使他们有.net知识.很多人都说用drupal的php在.NET框架上有许多优点,但没有说明它们是什么.很难相信脚本语言比编译语言有优势.我在这里错过了一些东西.
考虑我写的以下代码:
import Control.Monad
increasing :: Integer -> [Integer]
increasing n
| n == 1 = [1..9]
| otherwise = do let ps = increasing (n - 1)
let last = liftM2 mod ps [10]
let next = liftM2 (*) ps [10]
alternateEndings next last
where alternateEndings xs ys = concat $ zipWith alts xs ys
alts x y = liftM2 (+) [x] [y..9]
Run Code Online (Sandbox Code Playgroud)
' increasing n'应返回一个n位数字列表,其数字从左到右增加(或保持不变).
有没有办法简化这个?使用' let'和' liftM2'到处都看起来很难看.我想我错过了关于列表monad的重要内容,但我似乎无法摆脱它们.
我有#include<math.h>,我试图使用pow(x,y)和powf(x,y).但似乎它们都不符合c99标准.我用命令gcc -std=c99 test.c -o test编译.我可以使用什么功能?
例如,以下查询工作正常:
SELECT *
FROM quotes
WHERE expires_at <= '2010-10-15 10:00:00';
Run Code Online (Sandbox Code Playgroud)
但这显然是在执行'字符串'比较 - 我想知道是否有一个内置于MySQL的函数专门进行'datetime'比较.
我现在遇到一个小问题,这已经变成了一个令人讨厌的伤口。
我重新创建了Google营业时间,以设置公司在一周中的哪些时间营业,或者该营业日是否营业。现在,如果它们已关闭,则用户可以选择一个复选框,并且DIV隐藏的时间。现在,我使用.show()和.hide()
现在,假设用户关闭了第一天,并决定“全部应用”到一周中的其余天。我循环浏览并关闭剩余的6天。但是,如果用户在一周中的某一天修改了一天,则.show()或.hide()函数会自动添加"display: block",这会弄乱循环。
为什么jQuery为什么要在原来不存在的时候添加这种样式,并且在应用.show()or 之前有没有一种干净的方法可以在循环中删除它.hide()?