Hi Andreas,
When the application starts, first a page is displayed that
contains the
HelpBalloonDialog component, hence it's script expression is
compiled into
the expression cache. Then I open a page that uses the Dialog
component, now
it seems to retrieve the compiled expression for the other script
and poof!
Here is the exception:
[ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL
expression>'
of {component=$dialog_...@b03d85e5[assetsmanagement/fileManager.
$Dialog],
widget=dialog,
props={"bgColor":"black","bgOpacity":
0.4000000059604645
,"followScroll":true,"closeOnBackgroundClick":false,"blockDuration":
0,"lifeTime":0,"toggle":"fade","toggleDuration":150}}:
$Dialog_142 cannot be cast to
nl.relate4u.pcc.contexthelp.HelpBalloonDialog
org.apache.hivemind.ApplicationRuntimeException
location: classpath:/org/apache/tapestry/dojo/html/
Dialog.script, line
36, column 43
31 </unique>
32 </body>
33
34 <initialization>
35
tapestry.widget.synchronizeWidgetState("${component.clientId}",
"Dialog",
${props}, ${component.destroy});
36 <if expression="component.hidden">
37 dojo.widget.byId("${component.clientId}").hide
();
38 </if>
39 <if-not expression="component.hidden">
40 dojo.widget.byId("${component.clientId}").show
();
41 </if-not>
[ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL
expression>'
of {component=$dialog_...@b03d85e5[assetsmanagement/fileManager.
$Dialog],
widget=dialog,
props={"bgColor":"black","bgOpacity":
0.4000000059604645
,"followScroll":true,"closeOnBackgroundClick":false,"blockDuration":
0,"lifeTime":0,"toggle":"fade","toggleDuration":150}}:
$Dialog_142 cannot be cast to
nl.relate4u.pcc.contexthelp.HelpBalloonDialog
[ +/- ] Exception: $Dialog_142 cannot be cast to
nl.relate4u.pcc.contexthelp.HelpBalloonDialog
java.lang.ClassCastException
Stack Trace:
$ASTChain_12487ac4bf9.get($ASTChain_12487ac4bf9.java)
org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read
(ExpressionEvaluatorImpl.java:141)
org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read
(ExpressionEvaluatorImpl.java:110)
$ExpressionEvaluator_12487ac4a68.read
($ExpressionEvaluator_12487ac4a68.java)
org.apache.tapestry.script.ScriptSessionImpl.evaluate
(ScriptSessionImpl.java:86)
org.apache.tapestry.script.ScriptSessionImpl.evaluate
(ScriptSessionImpl.java:91)
org.apache.tapestry.script.AbstractToken.evaluateBoolean
(AbstractToken.java:102)
org.apache.tapestry.script.IfToken.evaluate(IfToken.java:43)
org.apache.tapestry.script.IfToken.write(IfToken.java:48)
org.apache.tapestry.script.AbstractToken.writeChildren
(AbstractToken.java:71)
org.apache.tapestry.script.InitToken.write(InitToken.java:43)
org.apache.tapestry.script.AbstractToken.writeChildren
(AbstractToken.java:71)
org.apache.tapestry.script.ParsedScript.execute(ParsedScript.java:82)
org.apache.tapestry.dojo.html.Dialog.renderWidget(Dialog.java:106)
(rest of stack trace omitted)
Here is the code for HelpBalloonDialog (the dialog component is the
standard
Tapestry component included in the distribution):
HelpBalloonDialog.java:
package nl.relate4u.pcc.contexthelp;
import java.util.HashMap;
import java.util.Map;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.IScript;
import org.apache.tapestry.TapestryUtils;
import org.apache.tapestry.dojo.AbstractWidget;
import org.apache.tapestry.services.ResponseBuilder;
/**
* Implementation of HelpBalloons, by calling custom javascript code.
*/
public abstract class HelpBalloonDialog extends AbstractWidget {
public abstract boolean isHidden();
public abstract void setHidden(boolean hidden);
public abstract String getIconElementId();
public abstract void setIconElementId(String v);
public abstract void setTitle(String title);
public abstract String getTitle();
public void show() {
setHidden(false);
}
public void hide() {
setHidden(true);
}
/**
* {...@inheritdoc}
*/
public void renderWidget(IMarkupWriter writer, IRequestCycle
cycle) {
if (!cycle.isRewinding()) {
writer.begin(getTemplateTagName()); // use element
specified
renderIdAttribute(writer, cycle); // render id="" client
id
renderInformalParameters(writer, cycle);
}
renderBody(writer, cycle);
if (!cycle.isRewinding()) writer.end();
if (!cycle.isRewinding()) {
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("component", this);
getScript().execute(this, cycle,
TapestryUtils.getPageRenderSupport(cycle, this), parms);
if (isResizing()) {
if
(!getResponseBuilder().isInitializationScriptAllowed(this)) {
getResponseBuilder().updateComponent(getId());
}
getResponseBuilder().addScriptAfterInitialization
(this,
"dojo.widget.byId('" + getClientId() +
"').checkSize();");
}
}
}
public abstract ResponseBuilder getResponseBuilder();
// TODO left over from Dialog code, do we need the resize stuff??
public abstract boolean isResizing();
public abstract void setResizing(boolean value);
/** injected. */
public abstract IScript getScript();
}
HelpBalloonDialog.jwc:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//
EN"
"http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
<component-specification
class="nl.relate4u.pcc.contexthelp.HelpBalloonDialog"
allow-body="yes" allow-informal-
parameters="yes">
<description>
Creates a HelpBalloon Dialog.
</description>
<parameter name="hidden" default-value="ognl:true" />
<parameter name="title" default-value="Help Title" />
<parameter name="iconElementId" default-value="unknown" />
<inject property="script" type="script"
object="HelpBalloonDialog.script"/>
</component-specification>
HelpBalloonDialog.script:
<?xml version="1.0"?>
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification
3.0//EN"
"http://tapestry.apache.org/dtd/Script_3_0.dtd">
<script>
<input-symbol key="component" required="yes" />
<initialization>
<if expression="component.hidden">
if (helpBalloonPlaceHolder) {
helpBalloonPlaceHolder.hide();
/*
* remove the help balloon dialog from the balloon
and put it
back
* under the helpBalloonUpdateArea (which is not
visible)
*/
var helpBalloonDialog =
document.getElementById('${component.clientId}');
helpBalloonDialog.parentNode.removeChild
(helpBalloonDialog);
document.getElementById('helpBalloonUpdateArea').appendChild
(helpBalloonDialog);
helpBalloonPlaceHolder = null;
}
</if>
<if-not expression="component.hidden">
/*
* The help balloon object will move the component from
the
* helpBalloonUpdateArea to under its own element
hierarchy,
* when we hide the balloon we move it back again, see
above.
*/
helpBalloonPlaceHolder = new HelpBalloon({
title: "${component.title}",
content: '${component.clientId}',
icon:
document.getElementById('${component.iconElementId}'),
returnElement: true,
anchorPosition: 'top right'
});
helpBalloonPlaceHolder.show();
</if-not>
</initialization>
</script>
On Oct 24, 2009, at 16:21 , Andreas Andreou wrote:
I can't really see what's going on.. is it possible to include the
exception and/or
some related code?
On Sat, Oct 24, 2009 at 2:44 PM, Marc van Kempen <m...@bowtie.nl>
wrote:
Hi,
I have copied and changed the Dialog component in my project
(Tapestry
4.1.5) in order to create a HelpBalloon popup. This gives me the
following
files that I've added to my project:
HelpBalloonDialog.java
HelpBalloonDialog.jwc
HelpBalloonDialog.script
I kept the condition checking the same as in Dialog.script, i.e.:
<script>
<input-symbol key="component" required="yes" />
<initialization>
<if expression="component.hidden">
do_stuff();
</if>
<if-not expression="component.hidden">
do_different_stuff();
</if-not>
</initialization>
</script>
This is essentially the same construction as Dialog.script uses,
and most
importantly the expression string "component.hidden" is exactly
the same.
Requesting a page however where Dialog is used gives me a cast
exception
when it tries to use the cached compiled expression that it finds.
Changing
the name "component" to something else makes the problem go away.
Now, looking at the code I'm seeing the following:
The ExpressionCache uses the symbol map in ScriptSessionImpl as
its key,
so
therefore the cache should be local to a script and I should be
allowed
to
use the same expression in different scripts.
Is this the intended behaviour, am I missing something or am I
looking at
a
bug?
Kind regards,
Marc van Kempen.
--
Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org