如何调试JSF / EL [英] how to debug JSF/EL

查看:204
本文介绍了如何调试JSF / EL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JSF页面中调试EL?我想看变量值,函数调用等等。最好的解决方案是eclipse插件,但任何其他的可能性都比猜测为什么这个表达式无法正确呈现?

How to debug EL in the JSF page? I'd like to watch variable values, function calls an so on. The best solution would be an eclipse plugin, but any other possibility is better than guessing "Why this expression failed to render correctly?".

推荐答案

最接近你在JSF / Facelets中可以获得的是放置一个 < ui:debug />

Closest what you can get in JSF/Facelets is placing an <ui:debug /> somewhere in the view:

<ui:debug />

Ctrl Shift D然后,应显示一个弹出窗口,其中包含有关组件树和所有可用请求参数以及request / view / flash / session / application作用域变量的调试信息。它基本上是所有这些地图的内容的表示。

Pressing CtrlShiftD should then show a popup window with debug information about the component tree and all available request parameters and request/view/flash/session/application scoped variables. It's basically a representation of the content of all those maps.

热键是由热键属性配置的方式所以你可以选择另一个,只要它与浏览器的默认热键冲突,就像在Firefox中一样;默认情况下, Ctrl Shift D 显示添加书签对话框。以下是您如何使用 Ctrl Shift X 来收听

The hotkey is by the way configureable by hotkey attribute so that you can choose another whenever it clashes with browser default hotkeys, as it would do in Firefox; CtrlShiftD would by default show the Add bookmarks dialogue. Here's how you could make it to listen on CtrlShiftX instead:

<ui:debug hotkey="x" />

您通常还希望将其隐藏在非开发阶段,因此添加一个呈现条件,如那个:

You'd usually also like to hide it in non-development stage, so add a rendered condition like that:

<ui:debug hotkey="x" rendered="#{facesContext.application.projectStage == 'Development'}" />

在显示的调试信息中,提供的关于作用域变量的信息不如你所期望的那么好。它只显示默认为 com.example.Bean@hashcode 的所有范围变量的 Object#toString() 。您不能直接像Eclipse调试器的调试视图中一样浏览其属性和属性值。您需要相应地在类上实现 toString(),以便尽可能地返回相关信息(如有必要,您甚至可以让Eclipse通过右键单击源自动生成源代码>生成toString()):

In the shown debug information, the information provided about scoped variables isn't that great as you would expect. It only shows the Object#toString() outcome of all scoped variables which defaults to com.example.Bean@hashcode. You can't explore their properties and the values of their properties directly like as you could do in debug view of Eclipse's debugger. You'd need to implement toString() on the class accordingly so that as much as possible relevant information is returned (if necessary, you can even let Eclipse autogenerate it by rightclick source code > Source > Generate toString()):

@Override
public String toString() {
    return String.format("Bean[prop1=%s,prop2=%s,prop3=%s]", prop1, prop2, prop3);
}

对于方法调用,只需在Java源代码上放置一个断点,办法。当EL调用该方法时,Eclipse也会启动它。如果它是一个托管bean,那么您还将看到它在Eclipse调试器中的属性。

As to method calls, just put a breakpoint on the Java source code the usual way. Eclipse will kick in there as well when EL calls the method. If it's a managed bean, you'll also just see its properties in the Eclipse debugger.

这篇关于如何调试JSF / EL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆