ADF:在 UI 上显示 debug/log 消息的快速简便方法是什么?

ADF: What is a quick and easy way to display a debug/log message on the UI?

所以我正在调试我的应用程序(开发和测试环境)中的一些代码,并且不允许我使用 appsloggers 或 System.out.print 或任何此类日志记录。

我想查看某些变量在给定时间保持的值,并放置诸如“进入第一个 If 循环”和“进入 x 函数”之类的消息。 该代码通常存在于 ManagedBean、VOImpl 和 AMImpl 以及一些 java 处理程序中。

在我的应用程序 UI 上显示某些内容(例如评论框或用于调试的警告消息)的最佳方式是什么? 如果我可以关闭消息框并继续代码流,那就太好了。

It would be great if I can close the message box and code flow continues.

您描述的是调试。在 Java 中,ADF 调试没有在 UI 中完成,也不应该。您可以在本地实例上使用 JDeveloper 调试器功能,或者将远程调试功能插入目标服务器。

https://download.oracle.com/otn_hosted_doc/jdeveloper/101301/java_app_dev/debug/deb_p_local.html 在 JDeveloper 中调试项目 确保您的代码是使用工具中的调试信息编译的,然后选择 ProjectProperties - 编译器,然后才能使用一些调试器功能,例如在数据 window.

中查看参数和局部变量
See About Debugger Icons to determine the purpose and functions of the various debugger icons displayed on the toolbar or in the debugger windows. Each of these commands is also available from the Debug main menu.

To set breakpoints and step through your code:

In a source editor, set a breakpoint on an executable statement by clicking in the margin to the left of the statement.
The unverified breakpoints icon red_dot appears in the left margin.
Select D ebug then choose Debug [filename.java] or click Debug Button on the toolbar.
The class runs and stops at the first breakpoint.
From the toolbar, click step_into_toolbar_icon Step Into to trace into a method call or click step_over_toolbar_icon Step Over to step over a method call.
Look in the Stack window to examine the sequence of method calls that brought your program to its current state. Double-click a method to display the associated source code in the source editor.
In the Smart Data and Data windows, examine the arguments and variables.
Display the Threads window to see the status of other threads in your program.

在您的目标服务器上进行远程调试: https://aboutsoa.wordpress.com/2009/03/10/remote-debugging-in-jdeveloper/

Open Enterprise Manager (http://{hostname}:{port}/em) and click on the oc4j_soa instance.
Click the Administration tab.
Click on Server Properties.
Under command-line options add the following line: -Xrunjdwp:transport=dt_socket,server=y,address=9901,suspend=n.
Click Apply and then be sure to restart the OC4J server.
Next you need to configure your JDeveloper project for remote debugging:

Right-click on the project and choose Project Properties.
Click the Run/Debug option.
Click on the default run configuration and click Edit…
Under the Launch Settings option make sure the Remote Debugging and Profiling checkbox is checked.
Choose the Debug > Remote option.

如果您仍想在 UI 上显示和提醒,您可以通过编程方式触发 javascript 提醒功能。
https://cedricleruth.com/how-to-execute-client-javascript-in-an-adf-java-bean-action/

  this.executeClientJavascript("alert('HERE IS MY VARIABLE VALUE, i should really use the debugger for this :)" + YOURJAVAVARTOSTRING + " ')");


//You should put this function in a util java class if you want to use it in multiple bean
public static void executeClientJavascript(String script) {
 FacesContext facesContext = FacesContext.getCurrentInstance();
 ExtendedRenderKitService service = Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
 service.addScript(facesContext, script);
}