- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 View 中有一个表单,例如:
form.xhtml
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="Name" />
<h:inputText value="#{bean.name}" />
<h:outputLabel value="Age" />
<h:inputText value="#{bean.age}"
converter="#{ageConverter}" />
<h:outputLabel value="" />
<h:commandButton action="#{bean.submit}"
value="Submit" />
</h:panelGrid>
</h:form>
由以下 bean 支持:
Bean.java
@Named
// Scope
public class Bean implements Serializable {
@Inject private Service service;
private String name;
private int age;
private List<Person> people;
public void submit() {
people= service.getPeople(name, age);
}
// getters & setters for name & age
// getter for people
}
导致人
的 View :
结果.xhtml
<h:form>
<h:dataTable value="#{bean.people}"
var="person">
<h:column>
<f:facet name="header">Name</f:facet>
#{person.name}
</h:column>
<h:column>
<f:facet name="header">Day of Birth</f:facet>
#{person.dayOfBirth}
</h:column>
</h:dataTable>
</h:form>
现在显然用例类似于: - 使用form.xhtml提交表单 - 使用Bean.java从服务中获取人员 - 向人们展示使用 result.xhtml
在此示例中,拼图仍有一小部分不完整。例如,范围对于结果中是否有 people
至关重要,此外,结果页面没有转发(或类似的内容)。
现在我不确定实现此目标的最佳(或至少是良好)方法是什么。以下是我能想到的一些方法:
@ViewScoped
(JSF2.2) 和隐式导航(从 submit()
返回 String
)导航到第二页。然而,这打破了视野(无论如何要完成这个)?@ViewScoped
并包含基于rendered=''
和一些EL的正确文件(form.xhtml或result.xhtml)。这可以通过提交时的 Ajax 调用来完成。name
和 age
作为请求中的 GET 参数传递给 result.xhtml,并在 @PostConstruct
上执行逻辑(但是,如果表格“巨大”怎么办)?在这种情况下,@RequestScoped
就足够了。我的问题是,完成这个用例的有效且良好(最佳)的方法是什么?
感谢您的投入。
最佳答案
我认为您正在寻找的是 flash scope 。它在重定向后仍然存在,但在后续请求中不再可用。
解决方案是通过 Flash 范围传递您的 name
和 age
变量,并使用它们来渲染结果。
关于java - 将变量传递给另一个 View : best practice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16622251/
上下文 我有一个日间 TUMBLINGWINDOW(类似于下面所示的) SELECT DATEADD(day, -1, System.Timestamp()) AS WindowStart
因此,我正在开发一个非常小的 Web 组件,以作为更大的设计系统的一部分。 我对网络组件的使用有点陌生,但我知道这个特定的网络组件可以在一个布局中使用很多很多次。 此 Web 组件控制在传递给它的任何
我刚刚开发了一个 Android 应用程序(minSdkVersion 23/targetSdkVersion 29),可以连接到 BluetoothLE 设备以定期获取数据。 现在,在 MainAc
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
我一直在阅读有关 Airplay SDK 和 Dragonfire SDK 的内容。这些是在没有 Mac 的情况下进行 iphone 开发的合法选择吗?大家有更好的解决办法吗? 最佳答案 由于签名等原
我正在考虑使用 DTO 而不是传递我的域对象。我在这里和其他地方都读过几篇文章,我知道有几种方法可以完成这项工作。 如果我总共只有大约 10 个域类,并且考虑到我想在我的 View (WPF 前端)中
我的问题是,如果我有一个列表 list = [1,2,3,4,5,6,7] 如果我想知道这个列表中元素的数量,是len(list) 或 list.count 更好的选择?还是 .count 仅适用于来
我想知道 Django Rest Framework 的最佳实践。我一直通过每个用户使用不同的序列化程序(员工、帐户所有者、其他人)和 HTTP 方法来限制更改帐户上某些属性的访问权限,但我觉得这太不
我有数百个用于测试组件的脚本。这些脚本中的每一个都包含一组下标和单独的记录。 下标可以在多个 TC_Level 脚本中使用,甚至可以在其他下标中使用。 每个脚本都有一个唯一的名称。 例子: TC_1
我正在建立一个以两种语言提供产品信息的网站:英文和中文。 每个产品必须有英文名称,也可以有中文名称。 每次请求产品页面时,request检查对象以确定产品名称应该以英文还是中文显示。在后一种情况下,如
场景:应用程序具有可以启用某些优化的算法。默认情况下,有些是打开的,有些是关闭的。在 Java 中是否有一种方便的方法来实现某种全局属性系统? 要求: 必须很容易两次使用不同的设置运行程序的多个实例
我从事嵌入式工作,我有一些管理硬件的软件模块。这个模块有状态,状态转换很复杂:根据事件,模块可以从状态 A 到状态 B 或者可能到 C .但是,当它退出某个状态时,它应该对硬件执行一些操作,以使其也保
我有一个免费网站,可以流式传输实时股票期权数据。我想让用户制作并保存他们自己的 JavaScript 可调用工具来解释选项数据。用户可以调用这些自定义工具来帮助他们自己做出有关期权的买卖决定。 但对于
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 2 年前。 社区在 6 个
我不是 DBA,我不知道什么是最好的解决方案。我有两个表, Custumers Table CustomerId (primary key, identity) ... 和 Suppliers Tab
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 7年前关闭。 Improve t
我一直在阅读关于版本控制主题的所有问题,但我认为我没有找到一个看起来像我自己的场景。 场景是: 我们有一个中型/大型 Web 应用程序,它有(至少应该有)一个部署到所有客户端的核心。当我们向客户演示应
我希望根据继承来组织一些项目,目的是确定哪些项目是连接最密集的父项,并且还只是看到形成的连接。 通常这将通过拓扑排序来完成,但我的图有循环。是否有类似“尽力而为”拓扑排序的东西,它可以尝试根据连接数或
以下在 JQuery 中附加事件处理程序的方法有什么区别? (function () { var $body = $("body"); $('button').click(functi
我是一名优秀的程序员,十分优秀!