You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by MSafiri <zs...@gmail.com> on 2010/12/03 08:39:40 UTC

Re: Script Problem - Accordion

Dear All,

We started to work on the accordion based GUI part of our application.
Followed the Tutorial, did all the modifications. However, when the
individual panels are loaded, the error message below appears:

javax.script.ScriptException:
sun.org.mozilla.javascript.internal.EvaluatorException: erreur de syntaxe
(<Unknown source>#3) in <Unknown source> at line number 3

                    		accordion.selectedIndex += 1;
}

Here is the code of the PushButton used to advance to the next panel:

<PushButton wtkx:id="nextButton" buttonData="Next"
      styles="{minimumAspectRatio:3}">
                <buttonPressListeners>
                	<wtkx:script>
                		importPackage(org.apache.pivot.wtk);
                    	function buttonPressed(button) {
                    		<!--- var accordion =
button.getAncestor("org.apache.pivot.wtk.Accordion"); -->
                    		accordion.selectedIndex += 1;
                    	}
					</wtkx:script>
                </buttonPressListeners>
            </PushButton>

If the variable declaration line is included, another error message appears.

I uploaded the complete code of one of the panel to show the structure. 

http://apache-pivot-users.399431.n3.nabble.com/file/n2010365/cstDelegatorDialogSummary.wtkx
cstDelegatorDialogSummary.wtkx 

Can anyone help out what can be the problem?

Thanks for the help,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Script-Problem-Accordion-tp1966316p2010365.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Script Problem - Accordion

Posted by Greg Brown <gk...@verizon.net>.
> I'll take a look at adding a String override to getAncestor() for Pivot 2.0.

FYI, I had apparently already added this method. So you can use a String in Pivot 2.0 instead of a Class.

G



Re: Script Problem - Accordion

Posted by MSafiri <zs...@gmail.com>.
Ok, I will check it with my colleague on Monday. He is working on the other
elements. 

Your help is appreciated! 

Thanks alot and have a good weekend,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Script-Problem-Accordion-tp1966316p2011634.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Script Problem - Accordion

Posted by Greg Brown <gk...@verizon.net>.
OK. You should try the following:

var accordion = button.getAncestor(org.apache.pivot.wtk.Accordion.class);

If that doesn't work you may need to write a helper function or method to convert a String to a Class. See getAncestor(String) in the 2.0 source for Component:

http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java

On Dec 3, 2010, at 8:27 AM, MSafiri wrote:

> 
> Dear Greg,
> 
> Yes, I did what you proposed. The set-up is the following: I have a wtkx
> file which is the main file for the accordion, its code is below:
> 
> <Window title="Accordions" maximized="true"
>    xmlns:wtkx="http://pivot.apache.org/wtkx"
>    xmlns="org.apache.pivot.wtk"
>    preferredWidth="500" preferredHeight="300">
>    <content>
>        <Accordion wtkx:id="accordion" styles="{padding:0}">
>            <panels>
>                <wtkx:include wtkx:id="destinationPanel"
> src="cstDelegatorDialogDestination.wtkx" Accordion.label="Destination"/>
> 				<wtkx:include wtkx:id="descriptionPanel"
> src="cstDelegatorDialogDescription.wtkx" Accordion.label="Description"/>
> 				<wtkx:include wtkx:id="budgetPanel" src="cstDelegatorDialogBudget.wtkx"
> Accordion.label="Budget"/>
> 				<wtkx:include wtkx:id="progressUpdatePanel"
> src="cstDelegatorDialogProgressUpdate.wtkx" Accordion.label="Progress
> Calculation"/>
>                <wtkx:include wtkx:id="summaryPanel"
> src="cstDelegatorDialogSummary.wtkx" Accordion.label="Summary"/>
>            </panels>
>        </Accordion>
>    </content>
> </Window>
> 
> Then I have 6 panels, which are the elements of the accordion. Each of them
> has a wtkx:id defined, and each wtkx:id is different, depending on the
> purpose of the panel.
> 
> The code used on each panel to advance to the next one is this:
> 
> <PushButton wtkx:id="nextButton" buttonData="Next"
>                styles="{minimumAspectRatio:3}">
>                <buttonPressListeners>
>                	<wtkx:script>
>                		importPackage(org.apache.pivot.wtk);
>                    	function buttonPressed(button) {
>                    		<!--- var accordion =
> button.getAncestor("org.apache.pivot.wtk.Accordion"); -->
>                    		accordion.selectedIndex += 1;
>                    	}
> 					</wtkx:script>
>                </buttonPressListeners>
>            </PushButton>
> 
> I hope I was able to give more information.
> 
> Regards,
> 
> MSafiri
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Script-Problem-Accordion-tp1966316p2011534.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Script Problem - Accordion

Posted by MSafiri <zs...@gmail.com>.
Dear Greg,

Yes, I did what you proposed. The set-up is the following: I have a wtkx
file which is the main file for the accordion, its code is below:

<Window title="Accordions" maximized="true"
    xmlns:wtkx="http://pivot.apache.org/wtkx"
    xmlns="org.apache.pivot.wtk"
    preferredWidth="500" preferredHeight="300">
    <content>
        <Accordion wtkx:id="accordion" styles="{padding:0}">
            <panels>
                <wtkx:include wtkx:id="destinationPanel"
src="cstDelegatorDialogDestination.wtkx" Accordion.label="Destination"/>
				<wtkx:include wtkx:id="descriptionPanel"
src="cstDelegatorDialogDescription.wtkx" Accordion.label="Description"/>
				<wtkx:include wtkx:id="budgetPanel" src="cstDelegatorDialogBudget.wtkx"
Accordion.label="Budget"/>
				<wtkx:include wtkx:id="progressUpdatePanel"
src="cstDelegatorDialogProgressUpdate.wtkx" Accordion.label="Progress
Calculation"/>
                <wtkx:include wtkx:id="summaryPanel"
src="cstDelegatorDialogSummary.wtkx" Accordion.label="Summary"/>
            </panels>
        </Accordion>
    </content>
</Window>

Then I have 6 panels, which are the elements of the accordion. Each of them
has a wtkx:id defined, and each wtkx:id is different, depending on the
purpose of the panel.

The code used on each panel to advance to the next one is this:

<PushButton wtkx:id="nextButton" buttonData="Next"
                styles="{minimumAspectRatio:3}">
                <buttonPressListeners>
                	<wtkx:script>
                		importPackage(org.apache.pivot.wtk);
                    	function buttonPressed(button) {
                    		<!--- var accordion =
button.getAncestor("org.apache.pivot.wtk.Accordion"); -->
                    		accordion.selectedIndex += 1;
                    	}
					</wtkx:script>
                </buttonPressListeners>
            </PushButton>

I hope I was able to give more information.

Regards,

MSafiri
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Script-Problem-Accordion-tp1966316p2011534.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Script Problem - Accordion

Posted by Greg Brown <gk...@verizon.net>.
As I explained earlier, getAncestor() does not provide an override that takes a String, only a Class. I had suggested giving your Accordion an ID - did you try that?

If your accordion panels are not defined in the same WTKX file as the accordion itself, then an ID won't work and you will have to use getAncestor(). I haven't tried passing a Class instance in JavaScript, but I imagine that it is possible. You should be able to do something like:

var accordion = button.getAncestor(org.apache.pivot.wtk.Accordion.class);

I'll take a look at adding a String override to getAncestor() for Pivot 2.0.

G

On Dec 3, 2010, at 2:39 AM, MSafiri wrote:

> 
> Dear All,
> 
> We started to work on the accordion based GUI part of our application.
> Followed the Tutorial, did all the modifications. However, when the
> individual panels are loaded, the error message below appears:
> 
> javax.script.ScriptException:
> sun.org.mozilla.javascript.internal.EvaluatorException: erreur de syntaxe
> (<Unknown source>#3) in <Unknown source> at line number 3
> 
>                    		accordion.selectedIndex += 1;
> }
> 
> Here is the code of the PushButton used to advance to the next panel:
> 
> <PushButton wtkx:id="nextButton" buttonData="Next"
>      styles="{minimumAspectRatio:3}">
>                <buttonPressListeners>
>                	<wtkx:script>
>                		importPackage(org.apache.pivot.wtk);
>                    	function buttonPressed(button) {
>                    		<!--- var accordion =
> button.getAncestor("org.apache.pivot.wtk.Accordion"); -->
>                    		accordion.selectedIndex += 1;
>                    	}
> 					</wtkx:script>
>                </buttonPressListeners>
>            </PushButton>
> 
> If the variable declaration line is included, another error message appears.
> 
> I uploaded the complete code of one of the panel to show the structure. 
> 
> http://apache-pivot-users.399431.n3.nabble.com/file/n2010365/cstDelegatorDialogSummary.wtkx
> cstDelegatorDialogSummary.wtkx 
> 
> Can anyone help out what can be the problem?
> 
> Thanks for the help,
> 
> MSafiri
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Script-Problem-Accordion-tp1966316p2010365.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.