Personal tools

Tips and Tricks

From OpenLaszlo

Contents

Command-Line Debugging

If you are debugging and you want to call lzc directly, and you want to see log messages for just a few specific classes in the console, you can do that, like so:

Create a file named $LPS_HOME/console- debug.properties containing something like this:

log4j.logger.org.openlaszlo.compiler.CanvasCompiler=DEBUG

that is:

log4j.logger.<package or class name>=<loglevel>

In your source code, create a logger for that class, or use the existing logger. CanvasCompiler.java declares:

private static Logger mLogger = Logger.getLogger(CanvasCompiler.class);

Then call methods on mLogger: debug, info, error, warn

mLogger.debug("(debug) Compiling canvas."); 
mLogger.info("(info) Compiling canvas.");
mLogger.error("(error) Compiling canvas.");

Then invoke the compiler with -lp console-debug.properties:

lzc -lp console-debug.properties test/hello.lzx

...and you'll see log messages for the level you specified and higher, for that class or package only.


Unsupported Features

Compiler Warnings

In LPS3.0b2: The compiler can already warn when you are making a global assignment, which is almost never what you want to do. The warning is off for now, because I need to add a pragma for silencing it when you actually mean to make a global assignment. But if you want to just proof an app to look for bugs like this, use

 lzc --options warnGlobalAssignments=true <your app>

and sift through the warnings by hand.

Other warnings you can enable in the same fashion:

 warnUnusedLocals -- warns if you declare a local variable and never use it
 warnUnusedParameters -- ditto for function parameters

Call Profiler

The call profiler generates statistics that can be used to measure the time spent in each function, and to generate a call graph.

XPath Debugging

These can be handy for XPath debugging:

Lazy Replication for Seamless scrolling of Images

To obtain smooth scrolling of images using BaseGrid you must alter basegrid.lzx in the LPS source.

First, add <simplelayout axis="y"/> after <view name="rowparent" width="${parent.width}"> on line 94. Second, change "lazy" to "normal" for the replication attribute at line 411.

These changes will allow smooth scrolling of images in a grid. If not modified the grid will lazily load images which will cause them to occasionally not render.

Checking for Whether a Property Exists (without warnings)

See CheckingPropertyExists.

Multi line edittext with scrollbar (Text Area)

Issue generally faced is that scrollbar wont show up or scroll bar doesn't move down as text is added

Step 1 Create Multi line Text area 
  • <view x="10" y="20" width="175" height="140" clip="true" bgcolor="0x6895F0">
  • <text id="chatMsg" multiline="true" fgcolor="white"/>
  • <scrollbar id="scroll"/>
  • </view>

Step 2 Add Scroll bar

Step 3 Move Text area down when text is added(As text is added scrollbar doesn't move automatically when text is added )

  • scroll.page(1);