- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在与 jsf 2
合作我发现有些行为很难解释或理解。
我有几个独立的h:form
s。
其中一个看起来像这样:
<h:form>
<h:commandButton value="#{text.General_Wipe_Now}" action="#{bean.doThate}" >
<f:ajax execute="@form" render="@form" />
</h:commandButton>
<h:selectBooleanCheckbox value="#{bean.ignoreErrors}">Ignore Errors</h:selectBooleanCheckbox>
</h:form>
我的问题是,每当我按下上述按钮时,我都会看到其他不相关的 bean 成员 getter(它们是其他形式的一部分)被调用。 (通过日志记录)
任何 getter 中都没有业务逻辑,但我想了解其原因。通过打印stacktrace
我确定JSF
确实是调用他们的人。
你建议我如何关注 JSF
了解为什么他们被称为?可能是什么原因?
谢谢!本。
更新
这是由正在运行但不应该运行的 getter 之一打印的堆栈跟踪。正如评论中所讨论的,在这个问题中包含所有相关的细节将非常复杂,因此我宁愿获得有关工具的帮助来自己找到答案。
java.lang.Exception
at com.aCompanyName.applicationName.beans.aBean.getSomethingFromBean(CurrentDevice.java:382)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
at org.apache.myfaces.view.facelets.component.UIRepeat.getValue(UIRepeat.java:248)
at org.apache.myfaces.view.facelets.component.UIRepeat.getDataModel(UIRepeat.java:211)
at org.apache.myfaces.view.facelets.component.UIRepeat._validateAttributes(UIRepeat.java:530)
at org.apache.myfaces.view.facelets.component.UIRepeat.visitTree(UIRepeat.java:763)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:797)
at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:992)
at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener._doTreeVisit(DebugPhaseListener.java:310)
at org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener.afterPhase(DebugPhaseListener.java:286)
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:111)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:185)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
更新2
正在制作 SSCCE,一旦我有了,就会更新。
更新3
问题似乎出现在 <ui:repeat>
上值属性。这是说明问题的 SSCCE 代码:
<h:body>
<ui:repeat var="str" value="#{admin.SList}">
STRING: #{str}
</ui:repeat>
<h:form>
<h:commandButton value="pressie" action="#{admin.doThat}">
<f:ajax execute="@form"/>
</h:commandButton>
</h:form>
</h:body>
Bean 代码:
@PostConstruct
public void init()
{
slist.add("Testing");
slist.add("This");
slist.add("Thing");
}
private List<String> slist = new ArrayList<String>();
public List<String> getSList(){
logger.trace("Getting LIST");
return slist;
}
public void doThat(){
logger.trace("DoThat Was Run");
}
按下按钮时,将输出到日志:
2011-08-16 16:55:55,853 TRACE [http-80-2] (AdminBean.java:80) - Getting LIST
2011-08-16 16:55:55,865 TRACE [http-80-2] (AdminBean.java:85) - DoThat Was Run
为什么要运行列表?这不是多余的吗?
最佳答案
我不使用 MyFaces,所以我不会详细介绍它。但值得一提的是,在 Mojarra 上 setter/getter 也被称为 <ui:repeat>
。然而,在我看来,堆栈对于正在发生的事情更加清楚。这是Thread#dumpStack()
直到FacesServlet#service()
:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1249)
at mypackage.Bean.getList(Bean.java:21)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at com.sun.faces.facelets.component.UIRepeat.getValue(UIRepeat.java:272)
at com.sun.faces.facelets.component.UIRepeat.getDataModel(UIRepeat.java:248)
at com.sun.faces.facelets.component.UIRepeat.setIndex(UIRepeat.java:442)
at com.sun.faces.facelets.component.UIRepeat.doVisitChildren(UIRepeat.java:661)
at com.sun.faces.facelets.component.UIRepeat.visitTree(UIRepeat.java:619)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:240)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:189)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
// Remnant omitted for brevity.
因此,当状态管理需要访问整个组件树时,就会在恢复 View 阶段发生这种情况。 UIRepeat
反过来,当要访问其子级时,需要设置行索引。
根据UIRepeat#doVisitChildren()
将行索引设置为 -1
。最终目标是仅访问树中的子级,而不是迭代模型值或渲染任何内容。它只需要 DataModel
为了能够设置行索引。数据模型的值是您看到正在调用 getter 的列表。如果一切正常,这个 getter 应该在恢复 View 阶段只调用一次。但是,如果它也在渲染响应阶段被调用,那么您可能会担心这一点,因为它完全没有必要。
关于java - 弄清楚为什么当我不希望调用 JSF getter 时会调用它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078477/
对于我不断地用刽子手问题来打扰这个论坛,我深表歉意。我希望很快就能完成这件事。确实在这方面一直在努力。这是到目前为止我的代码: #include #include #include #defin
这篇文章是 this one 的延续. 我试图了解我是否是唯一一个错过并需要 .NET 泛型类型继承其泛型参数类型之一的能力的人。 面临的挑战是收集支持此功能的令人信服的理由,或者,要知道没有。 我给
我正在使用下面的代码设计一个 3 小时的 JavaScript 倒计时 var count = 10800; var counter = setInterval(timer, 1000); //1
我正在处理验证并放置一个 html 模式属性,并希望在不点击保存/提交按钮的情况下查看错误消息。当我在字段外单击时,它应该根据我的模式条件进行验证。 这是我的代码: Extra Credit Da
我有一个像这样的 mysql 表结构: id int primary key name varchar start_time float 数据可能是这样的: id name
我试图在桌面上保留一张带有描述的图片,然后在移动设备上希望图片在左边,描述在右边……更多的是尽可能让所有内容都在首屏。 我希望桌面上的 DIV 是: 一个一个 BBB 但是在手机上: A B A B
我通过 Stackoverflow 进行了搜索,发现很多人试图避免 CSS 列中的重叠,但实际上我被要求让文本和图像重叠。 更新: 更好的图像解释了我被要求做的事情,以及指向我正在使用的代码的链接。谢
我在我的框架中设置了几个协议(protocol)来处理资源。在其中一个协议(protocol)中,我设置了一个扩展来为 decode 函数提供默认实现。显示代码和发生的情况更简单(请参阅对 fatal
我想同时加载,或者在上面的图像之后立即加载。它会在图像和标题 div 在预加载器内旋转之前不断加载 - 不好!这是 HTML: ✕ Various inv
我目前正在开发一个小游戏。我使用 getKeyCode 来移动我的角色,但问题是我不希望你在按住按钮的情况下能够继续移动。无论如何,我是否可以使用 getKeyCode 仅在第一次单击时注册,然后在释
我需要设置 width 或 max-width 才能让 margin:auto 工作,对吗? Like in this jsFiddle . 问题是,段落宽度等于 max-width,因此文本 blo
您好,我在同一页面上有一个表单和一个 Paypal 订阅按钮。在重定向到 Paypal 付款之前,我想在单击提交表单(通过电子邮件发送给我)时订阅按钮。 > >
我想让用户在点击一个文本字段时感觉就像我们点击一个按钮,在释放按钮后它会在很短的时间内变成橙色,然后闪烁并再次变成它的第一种颜色。当我点击它时它运行良好但没有出现颜色闪烁。 布局文件 主要 Ac
我怎样才能让我的 MediaPlayer 继续播放,即使在手机锁定和屏幕关闭的情况下,我认为它可能必须做一些使其成为服务但不确定的事情。如果是这样,我该如何将其更改为服务,或者是否有更快更简单的修复方
有人可以帮助我理解内存泄漏的概念以及特定数据结构如何促进/防止它(例如链表、数组等)。前段时间我被两个不同的人教过两次——由于教学方法的不同,这让我有点困惑。 最佳答案 维基百科有一个 good de
我希望 HTML 表单在提交后不执行任何操作。 action="" 不好,因为它会导致页面重新加载。 基本上,我希望在按下按钮或有人在输入数据后点击 Enter 时调用 Ajax 函数。是的,我可以删
我正在执行一个程序 say A from another,首先是 fork-ing,然后是 execve()。现在的问题是我希望 A 使用我通常使用 LD_PRELOAD 来完成的库。我如何在 exe
我目前正在为我们公司测试 Autofac。 我们希望有以下规则: 如果接口(interface)只实现了一次,则使用 builder.RegisterAssemblyTypes 自动添加它(见下文)。
正如 Scott Meyers 和 Andrei Alexandrescu 在 this 中概述的那样文章 简单尝试实现双重检查锁定实现在 C++ 中特别是不安全的,并且通常在不使用内存屏障的多处理器
目前我有一些代码可以在点击时改变图像,但这段代码是在一个 php HTML 循环中所以事情变得棘手,点击一个开关会使每个故事的开关都激活,因为它是基于 CSS 运行的.如何让它们独立交换? $("
我是一名优秀的程序员,十分优秀!