The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

badbad214 (4) [Avatar] Offline
#1
Hello all,
Here is the error code I get when using the code from the book and downloaded:

Error: Syntax error: the attribute value ended in mid-expression at line 8, column 1.
Look for an unclosed '(', '{', or '['.org.openlaszlo.sc.parser.ParseException: Syntax error: the attribute value ended in mid-expression at line 8, column 1.
Look for an unclosed '(', '{', or '['.
at org.openlaszlo.sc.parser.Parser.generateParseException(Parser.java:930smilie
at org.openlaszlo.sc.parser.Parser.jj_consume_token(Parser.java:9183)
at org.openlaszlo.sc.parser.Parser.PrimaryExpression(Parser.java:394)
at org.openlaszlo.sc.parser.Parser.CallExpression(Parser.java:974)
at org.openlaszlo.sc.parser.Parser.PostfixExpression(Parser.java:1192)
at org.openlaszlo.sc.parser.Parser.UnaryExpression(Parser.java:1307)
at org.openlaszlo.sc.parser.Parser.MultiplicativeExpression(Parser.java:1389)
at org.openlaszlo.sc.parser.Parser.AdditiveExpression(Parser.java:1465)
at org.openlaszlo.sc.parser.Parser.ShiftExpression(Parser.java:1543)
at org.openlaszlo.sc.parser.Parser.RelationalExpression(Parser.java:1646)
at org.openlaszlo.sc.parser.Parser.EqualityExpression(Parser.java:1723)
at org.openlaszlo.sc.parser.Parser.BitwiseANDExpression(Parser.java:1789)
at org.openlaszlo.sc.parser.Parser.BitwiseXORExpression(Parser.java:1852)
at org.openlaszlo.sc.parser.Parser.BitwiseORExpression(Parser.java:1915)
at org.openlaszlo.sc.parser.Parser.LogicalANDExpression(Parser.java:195smilie
at org.openlaszlo.sc.parser.Parser.LogicalORExpression(Parser.java:2001)
at org.openlaszlo.sc.parser.Parser.ConditionalExpression(Parser.java:2044)
at org.openlaszlo.sc.parser.Parser.AssignmentExpression(Parser.java:2179)
at org.openlaszlo.sc.parser.Parser.AssignmentExpression(Parser.java:2203)
at org.openlaszlo.sc.parser.Parser.ArgumentList(Parser.java:55smilie
at org.openlaszlo.sc.parser.Parser.Arguments(Parser.java:516)
at org.openlaszlo.sc.parser.Parser.CallExpression(Parser.java:993)
at org.openlaszlo.sc.parser.Parser.PostfixExpression(Parser.java:1192)
at org.openlaszlo.sc.parser.Parser.UnaryExpression(Parser.java:1307)
at org.openlaszlo.sc.parser.Parser.MultiplicativeExpression(Parser.java:1389)
at org.openlaszlo.sc.parser.Parser.AdditiveExpression(Parser.java:1465)
at org.openlaszlo.sc.parser.Parser.ShiftExpression(Parser.java:1543)
at org.openlaszlo.sc.parser.Parser.RelationalExpression(Parser.java:1646)
at org.openlaszlo.sc.parser.Parser.EqualityExpression(Parser.java:1723)
at org.openlaszlo.sc.parser.Parser.BitwiseANDExpression(Parser.java:1789)
at org.openlaszlo.sc.parser.Parser.BitwiseXORExpression(Parser.java:1852)
at org.openlaszlo.sc.parser.Parser.BitwiseORExpression(Parser.java:1915)
at org.openlaszlo.sc.parser.Parser.LogicalANDExpression(Parser.java:195smilie
at org.openlaszlo.sc.parser.Parser.LogicalORExpression(Parser.java:2001)
at org.openlaszlo.sc.parser.Parser.ConditionalExpression(Parser.java:2044)
at org.openlaszlo.sc.parser.Parser.AssignmentExpression(Parser.java:2179)
at org.openlaszlo.sc.parser.Parser.Expression(Parser.java:2241)
at org.openlaszlo.sc.parser.Parser.ExpressionStatement(Parser.java:2902)
at org.openlaszlo.sc.parser.Parser.ToplevelStatement(Parser.java:2325)
at org.openlaszlo.sc.parser.Parser.Statement(Parser.java:2423)
at org.openlaszlo.sc.parser.Parser.StatementList(Parser.java:4876)
at org.openlaszlo.sc.parser.Parser.Block(Parser.java:2653)
at org.openlaszlo.sc.parser.Parser.FunctionDeclaration(Parser.java:4240)
at org.openlaszlo.sc.parser.Parser.ModifiedDefinition(Parser.java:4583)
at org.openlaszlo.sc.parser.Parser.Directive(Parser.java:461smilie
at org.openlaszlo.sc.parser.Parser.Program(Parser.java:4543)
at org.openlaszlo.sc.Compiler$Parser.parse0(Compiler.java:546)
at org.openlaszlo.sc.Compiler$Parser.parse(Compiler.java:562)
at org.openlaszlo.sc.Compiler.dependenciesForFunction(Compiler.java:427)
at org.openlaszlo.sc.Compiler.dependenciesForExpression(Compiler.java:420)
at org.openlaszlo.compiler.NodeModel$CompiledAttribute.getDependenciesMethod(NodeModel.java:299)
at org.openlaszlo.compiler.NodeModel.addProperty(NodeModel.java:971)
at org.openlaszlo.compiler.NodeModel.addProperty(NodeModel.java:980)
at org.openlaszlo.compiler.NodeModel.addAttributes(NodeModel.java:881)
at org.openlaszlo.compiler.NodeModel.elementAsModelInternal(NodeModel.java:47smilie
at org.openlaszlo.compiler.NodeModel.elementAsModel(NodeModel.java:446)
at org.openlaszlo.compiler.NodeModel.addChildren(NodeModel.java:1162)
at org.openlaszlo.compiler.NodeModel.elementAsModelInternal(NodeModel.java:503)
at org.openlaszlo.compiler.NodeModel.elementAsModel(NodeModel.java:446)
at org.openlaszlo.compiler.NodeModel.addChildren(NodeModel.java:1162)
at org.openlaszlo.compiler.NodeModel.elementAsModelInternal(NodeModel.java:503)
at org.openlaszlo.compiler.NodeModel.elementAsModel(NodeModel.java:446)
at org.openlaszlo.compiler.NodeModel.addChildren(NodeModel.java:1162)
at org.openlaszlo.compiler.NodeModel.elementAsModelInternal(NodeModel.java:503)
at org.openlaszlo.compiler.NodeModel.elementAsModel(NodeModel.java:446)
at org.openlaszlo.compiler.ViewCompiler.compileXML(ViewCompiler.java:175)
at org.openlaszlo.compiler.ViewCompiler.compile(ViewCompiler.java:110)
at org.openlaszlo.compiler.Compiler.compileElement(Compiler.java:750)
at org.openlaszlo.compiler.CanvasCompiler.compile(CanvasCompiler.java:183)
at org.openlaszlo.compiler.Compiler.compileElement(Compiler.java:750)
at org.openlaszlo.compiler.Compiler.compile(Compiler.java:483)
at org.openlaszlo.compiler.Compiler.compile(Compiler.java:182)
at org.openlaszlo.cm.CompilationManager.compileItem(CompilationManager.java:720)
at org.openlaszlo.cm.CompilationManager.getItem(CompilationManager.java:444)
at org.openlaszlo.cm.CompilationManager.getLastModified(CompilationManager.java:412)
at org.openlaszlo.servlets.responders.ResponderCompile.getLastModified(ResponderCompile.java:394)
at org.openlaszlo.servlets.responders.ResponderCompile.respondImpl(ResponderCompile.java:17smilie
at org.openlaszlo.servlets.responders.Responder.respond(Responder.java:265)
at org.openlaszlo.servlets.LZServlet._doGet(LZServlet.java:441)
at org.openlaszlo.servlets.LZServlet.doGet(LZServlet.java:355)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:19smilie
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:619)

Please can anyone tell me if there is an issue with my Laszlo installation?

Regards
Alexandre Bessy
badbad214 (4) [Avatar] Offline
#2
Re: Chapter 5 code 5.11
OK if someone encounter the same issue...
in the first handler oninit in the if the {} are missing for the else:
<handler name="oninit">
if (LzBrowser.getInitArg("lzunit") == "true") {
gController.setAttribute("appstate", "UnitTest");
canvas.setAttribute("unittest", true);
}
else {
gController.setAttribute("appstate", "Login to Main");
}
</handler>

smilie
Still nopt working 100% (missing the button to change page now) but work in progress.
badbad214 (4) [Avatar] Offline
#3
Re: Chapter 5 code 5.11
ok next issue was in the switch():
in the book it is written switch(state) and it was not working for me so changed it to switch(appstate).
And few other things... so here is the code I am now using and seems to be working:

<canvas debug="true" bgcolor="0xCCCCCC">
<include href="lzunit"/>
<include href="resources.lzx"/>


<script>
asynchronoustests = false
</script>

<attribute name="unittest" value="false" type="boolean"/>

<handler name="oninit">
gController.setAttribute("appstate", "Login to Main");
</handler>

<node name="gController">
<attribute name="appstate" value="" type="string"/>
<attribute name="currstate" value="" type="string"/>

<handler name="onappstate" args="state">
switch (appstate) {
case "Splash to Login":
this.setAttribute("currstate", "Login");
break;
case "Login to Main":
this.setAttribute("currstate", "Main");
break;
case "Main to Checkout":
this.setAttribute("currstate", "Checkout");
break;
case "Checkout to Main":
this.setAttribute("currstate", "Main");
break;
case "UnitTest":
//Display an error message
break;
}
Debug.write(gController.currstate)
</handler>
</node>

<view name="Main" width="100%" height="100%">
<view name="header" width="20%" height="30%" >
resource="logo" x="30" y="15"/>
<window name="details" title="Product Details" >
x="${Main.header.width}"
width="55%" height="50%" resizable="true"/>
<window name="shopcart" title="Shopping Cart" x="75%" >
width="25%" height="65%" resizable="true">

<state apply="${gController.currstate == 'Main'}">
<button align="center" >
text="Checkout" y="80%" width="100">
<handler name="onclick">
this.setAttribute("text", "Return to Store");
gController.setAttribute("appstate", "Main to Checkout");
</handler>
</button>
</state>

<state apply="${gController.currstate == 'Checkout'}">
<button align="center" >
text="Return to Store" y="80%" width="100">
<handler name="onclick">
this.setAttribute("text", "Checkout");
gController.setAttribute("appstate", "Checkout to Main");
</handler>
</button>
</state>


</window>

<window name="browse" title="Browse Search" >
y="${Main.header.height}"
width="20%" height="70%" resizable="true"/>
<window name="productlist" title="Product List" >
x="${Main.browse.width}"
y="${Main.details.height}"
width="55%" height="50%" resizable="true"/>
<window name="mediaplayer" title="Media Player" >
x="${Main.browse.width+Main.productlist.width}"
y="${Main.shopcart.height}"
width="25%" height="35%" resizable="true">
<view stretches="both" >
width="100%" height="100%" resource="video"/>
</window>
</view>

<view name="checkout" x="${Main.x+Main.width}" >
width="75%" height="100%">
<tabslider name="checkoutsteps" >
width="100%" height="100%"
spacing="2" slideduration="300">
<tabelement text="Shipping Information"/>
<tabelement text="Billing Information"/>
<tabelement text="Order Confirmation"/>
</tabslider>
</view>

<state apply="${gController.appstate == 'Checkout to Main'}">
<animator target="Main" attribute="x" >
duration="700" to="0"
onstop="if (canvas.testsuite) testsuite.testcase.Main_test()"/>
</state>

<state apply="${gController.appstate == 'Main to Checkout'}">
<animator target="Main" attribute="x" >
duration="700" to="${-(canvas.width*.75)}"
onstop="if (canvas.testsuite) testsuite.testcase.checkout_test()"/>
</state>

<state name="testsuitestate" apply="false">
<TestSuite name="testsuite">
<TestCase name="testcase">
<method name="testCheckout">
gController.setAttribute("appstate", "Main to Checkout");
</method>
<method name="checkout_test">
assertEquals(-(canvas.width*.75), Main.x);
gController.setAttribute("appstate", "Checkout to Main");
</method>
<method name="Main_test">
assertEquals(0, Main.x);
</method>
</TestCase>
</TestSuite>
</state>
</canvas>

Good luck to all users smilie
AB