Introduction
From release 2.6 swiwml2 has included scripting features (JSR223)
Example
<?xml version="1.0" encoding="UTF-8" ?>
<dialog
xmlns="http://www.swixml.org/2007/Swixml"
xmlns:script="http://www.swixml.org/2007/Swixml/script"
resizable="true"
title="Example Script usage"
undecorated="false"
alwaysOnTop="true"
defaultCloseOperation="JFrame.HIDE_ON_CLOSE"
modal="false"
>
<!--
JAVA SCRIPT THAT DEFINE 'CLOSE' ACTION
client ==> Rendered object
application ==> Application' rendering object
-->
<script>
function close(e) {
client.setVisible(false);
application.exit();
}
</script>
<panel layout="borderLayout">
<vbox constraints="BorderLayout.CENTER">
<!-- CLASSIC ACTION BINDING -->
<Button name="tb" id="toggleButton" text="action" action="onCLick" />
<box.vstrut height="10"></box.vstrut>
</vbox>
<hbox constraints="BorderLayout.SOUTH">
<!-- SCRIPT ACTION BINDING -->
<button text="close" script:action="close"/>
</hbox>
</panel>
</dialog>
Any idea why I would get this error ?
// org.jdom.input.JDOMParseException: Error on line 21: The prefix "script" for attribute "script:action" associated with an element type "button" is not bound. //
Are you using 2.6-SNAPSHOT from repository https://oss.sonatype.org/content/repositories/snapshots ?
Please report bug in Issues section http://code.google.com/p/swixml2/issues/list
Ah - that'll be why - I was using the released 2.5 dist - I should have read the notes better. I'll check out 2.6 another time (I have to work out how to retrieve those snapshots). Thanks for getting back on this.
Is there a way that one can use java script function in eval expression?
For example in the above example I want to set button text through java script function like this. ......... .........
...... ...... <Button name="tb" id="toggleButton" text="${script:getButtonLabel()}" action="onCLick" /> ..... .....Hi
Idea, behind the script introduction,is to achieve what you are asking for
At the moment i've implemented, throught script, just actions' evaluation ...
I've planned to introduce generic attribute evaluation, but until now i hadn't time to work on it
I've opened the Issue 79 .. stay tune on it
Thx for feedbak Bartolo
Hi,
That way we can cleanly separate the markup and logic and test them in isolation.