- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<zk>
<grid width="auto" sizedByContent="true" span="1" sclass="tblWithoutHover">
<attribute name="onCreate">
authorPublisherEtcInclude.insertBefore(self, authorBox);
</attribute>
<columns>
<column/>
<column/>
</columns>
<rows>
<row valign="center">
<cell colspan="2"><label use="${authorPublisherComponents.originalFieldsLabel}"/></cell>
</row>
<row valign="center">
<label use="${authorPublisherComponents.titleAuthorOriginalLabel}"/>
<textbox use="${authorPublisherComponents.titleAuthorOriginalTextbox}"/>
</row>
<row valign="center">
<label use="${authorPublisherComponents.mainAuthorOriginalLabel}"/>
<textbox use="${authorPublisherComponents.mainAuthorOriginalTextbox}"/>
</row>
<row valign="center">
<label use="${authorPublisherComponents.mainAuthorResponsibilityLabel}"/>
<selectbox use="${authorPublisherComponents.mainAuthorResponsibilitySelectbox}"/>
</row>
<row valign="center">
<label use="${authorPublisherComponents.authorityDatesOriginalLabel}"/>
<textbox use="${authorPublisherComponents.authorityDatesOriginalTextbox}"/>
</row>
<row valign="center">
<cell>
<label use="${authorPublisherComponents.addMainAuthorsOriginalLabel}"/>
<toolbarbutton use="${authorPublisherComponents.addAuthorButton}"/>
</cell>
<cell id="addAuthorsCell">
<grid id="addAuthorsContainer" model="@bind(ivm.inventory.addAuthorsBeans)">
<columns>
<column/>
<column/>
<column/>
</columns>
<rows>
<row>
<textbox value="@load(xgbfxb.authorName)" onChange="@command('test', component = self, index=s.index)"/>
<button label="Del" onClick="@command('delAuthor', container=addAuthorsContainer, index=modelIndex )">
<custom-attributes modelIndex="${s.index}"/>
</button>
</row>
</rows>
</grid>
<textbox use="${authorPublisherComponents.addMainAuthorsOriginalTextbox}"/>
</cell>
</row>
这是我的 zul 页面的一部分。 addAuthorsBeans 是带有字段的类列表。当我更改组合框中的数据时,应用程序会为列表中的所有类调用 set 方法,但我希望它只调用相应的项目。是否可以?或者我应该使用 onChange 事件和 ViewModel 方法施展黑魔法吗?
编辑(21/12/2013)。它是这样工作的:我有三个项目 1、2、3。然后我为 2 个项目激活 setAuthor。然后应用程序为 2 个项目调用 setAuthor 方法,然后为 3 个项目,然后为 1 个项目,然后在容器中查找此方法。
我有“黑魔法”临时解决方案来创建静态变量并在第一次调用 setAuthor 方法时更改它并在容器中取消阻止它。
但这不是最终的解决方案,因为它会消耗更多的资源,而且实际上并不是它应该如何工作。
解决方案:如果您在另一个网格中有模型的网格,它会表现得很奇怪。所以只需使用列表框即可。
最佳答案
combobox
只会触发代表项目的对象的 item.setAuthorName(...)
。如果调用了其他 setter ,则必须在链接到此的 ViewModel 类中具有 @NotifyChange
或 @DependsOn
。
编辑:尝试改变:
<grid model="@bind(ivm.inventory.addAuthorsBeans)">
到
<grid model="@load(ivm.inventory.addAuthorsBeans)">
更新:我为这个主题创建的一个工作示例:http://forum.zkoss.org/question/90188/notifychange-to-grid-that-is-inside-a-row-of-another-grid/?answer=90284#post-id-90284 ):
第一个简单的 pojo 类:
package be.chillworld;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author chillworld
*/
public class Person {
private int id;
private String naam;
private List<Person> childs = new ArrayList<Person>();
public Person(int id) {
this.id = id;
naam = "test " + id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public void setNaam(String naam) {
this.naam = naam;
}
public String getNaam() {
System.out.println("asked getter (naam) of "+ id);
return naam;
}
public List<Person> getChilds() {
System.out.println("asked getter (childs) of "+ id);
return childs;
}
public void setChilds(List<Person> childs) {
this.childs = childs;
}
public boolean addChild(Person person) {
return childs.add(person);
}
@Override
public String toString() {
return "Person{" + "id=" + id + ", name=" + getNaam() + '}';
}
}
然后是 IndexVM:
package be.chillworld;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
/**
*
* @author chillworld
*/
public class IndexVm {
private List<Person> persons;
int i;
public IndexVm() {
System.out.println("starting creating list");
persons = new ArrayList<Person>();
for (i = 0; i < 100; i++) {
Person person = new Person(i);
person.addChild(new Person(++i));
persons.add(person);
}
System.out.println("ending creating list");
}
public List<Person> getPersons() {
return persons;
}
public void setPersons(List<Person> persons) {
this.persons = persons;
}
@Command
public void showIndex(@BindingParam("person") Person person) {
System.out.println("changed name");
person.setNaam("Chillworld");
BindUtils.postNotifyChange(null, null, person, "naam");
}
@Command
public void addChild(@BindingParam("person") Person person) {
System.out.println("add child");
Person child = new Person(++i);
child.setNaam("new child");
person.addChild(child);
BindUtils.postNotifyChange(null, null, person, "childs");
}
}
最后是 index.zul :
<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.zkoss.org/2005/zul"
xsi:schemaLocation="http://www.zkoss.org/2005/zul
http://www.zkoss.org/2005/zul/zul.xsd">
<window border="normal" closable="false"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('be.chillworld.IndexVm')">
<grid width="1000px" model="@load(vm.persons)">
<columns>
<column label="naam" />
<column label="add child" />
<column label="childs" />
</columns>
<template name="model" >
<row>
<textbox value="@bind(each.naam)" />
<button onClick="@command('addChild',person = each)" label="add child"/>
<grid width="400px" model="@load(each.childs)">
<columns>
<column label="naam" />
<column label="button" />
</columns>
<template name="model" var="item">
<row>
<textbox value="@bind(item.naam)" />
<button onClick="@command('showIndex',person = item)" label="change value"/>
</row>
</template>
</grid>
</row>
</template>
</grid>
</window>
</zk>
这给出了输出(启动后):
changed name
asked getter of 11
changed name
asked getter of 7
changed name
asked getter of 19
问候寒意。
关于java - zk - 是否可以为模型中的每条记录添加绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20704519/
我创建了一个带有列表框和按钮的网页,问题是当页面加载时,两个组件的右侧都会出现一个空白区域,但是如果调整页面大小,这些空白区域就会消失。
我正在使用 ZK 图表进行项目使用 MVC 方法,我想做的就是更改背景或向特定列添加指南(具有不同颜色),例如索引为 3 的列:我想要实现的目标 这是我的图表: 这是我想要的,在索引为 3 的列中使用
我正在集成 jquery 和 zk 项目。我的目标是将值从 js/jquery 端传递到 java 端,但徒劳无功。这是我引用的代码:use zAu to send data from client
尝试通过 ZK 6.0.1 Component Development Essentials 创建自定义 UI 组件。尝试使用自定义组件时,日志中总是出现错误“http://localhost:808
我正在使用 Zk 框架并尝试从 zhtml 页面获取 url 参数。我试过: Executions.getCurrent().getParameter("param"); 尽管我在客户端尝试了 zsc
您好,我正在尝试比较 zk 和 gwt 的性能。 在我的比较中,如果框架本身将一些代码转换为 js 就可以了(比如 gwt),我不能自己编写任何 javascript,但我不能自己编写 js 在以上述
当 ZK 组件被销毁或分离时,是否有可能通知监听器? 我希望不同的组件组合器通过事件队列进行通信。为此,我将这些组件的监听器订阅到事件队列。现在我需要知道组件或其 Composer 何时被销毁才能取消
我用 struts 1 配置了 zk。我创建了一个列表并在 session 中设置。 List nameList = new ArrayList(); nameList.add( "xxx" ); n
我想基于 zk 组合框制作新的 zk 组件,以保存以前输入的历史记录。我想将这些先前的输入存储在客户端的 localStorage 中。所以我必须使用 JavaScript 在客户端填充组合框,但不知
我在我的应用程序中使用 ZK colorbox,我想将 Colorbox 的 getRGB() 方法的 RGB 值转换为十六进制。 我有什么办法可以做到这一点吗? 最佳答案 您可以使用 org.zko
是否可以将 Spring bean 直接注入(inject)到 ZK backing bean 中? 在教程中,例如 this我只找到了一个示例,其中应用程序上下文是从复杂的 Web 应用程序中手动提
本文整理了Java中org.apache.ignite.spi.discovery.zk.internal.ZookeeperClient.zk()方法的一些代码示例,展示了ZookeeperClie
我安装了 Eclipse Juno 并添加了 ZK Studio 插件。我的Java JDK是1.5。 但是,当我尝试创建新项目时,出现如下错误: The selected wizard could
我收到以下异常 org.zkoss.zk.ui.UiException 和 java.lang.NumberFormatException。有人可以帮忙吗?我的堆栈跟踪如下: Nov 08, 2013
我正在尝试对现有的 ZK Controller 进行单元测试,并且我想找到一种方法来在对我的 Controller 进行单元测试时处理如下调用, Sessions.getCurrent().setAt
我正在运行 Spark 2.0.2 和 Mesos 0.28.2。 我正在尝试向 Spark 提交一个应用程序,使用 ZooKeeper 管理的 Mesos 集群作为主节点: $SPARK_HOME/
当我在MVVM方法的包含页面中使用Hflex属性时,它不起作用。 当我在另一个页面中包含某个页面时,就会发生此问题,并且此页面的组件的大小由hflex属性控制。我已经尝试过在父窗口加载时使用inval
我在带有zk-grails插件的grails 2.3.11中有一个应用程序。当我执行Spring Security Core集成进行身份验证时,zul页面会停止响应,并出现以下错误:“服务器暂时无法使
ZK支持检查元素是否有焦点吗? HtmlBasedComponent 具有 focus() 和 setFocus(boolean) 来设置焦点..但我没有看到任何 getFocus(). 具体来说,我
关于如何干净、稳健地将用户重定向回上一页有什么想法吗? 如果上一页位于应用程序本身内,我只关心将它们重定向回来。我曾考虑过在用户的 session 中存储某种 DIY 历史记录,但这似乎并不干净或健壮
我是一名优秀的程序员,十分优秀!