0

Logical Operators

asked 2008-09-03 15:10:51 +0800

zuzsso gravatar image zuzsso
48

updated 2008-09-03 15:19:52 +0800

Hi there. I have a problem with Java scripts.
I have this piece of code:

<zscript language="Java">
void aMethod() Source Code
   {//Method starts
      //Declarations--------------------------
         String logVal;
         String pasVal;
      //Sentences-----------------------------     
         logVal="a Value";
         pasVal= "otherValue";
         //Let check if values are the same
         if (logVal.equals(pasVal) & (logVal!=null))
            {//If Block starts
               //Entry Condition: Two values match and logVal is not null
               alert ("You're Logged in")
            }//If Block endss
         else
            {//Else block starts
               //Entry Condition: Two values don't macth or logVal is null
               alert ("You aren't logged in, try again");
            }//Else block endss
   }//Method endss
</zscript>


I built the application and load the page onto the browser. Tomcat reply with an error message: "The entity name must inmediately follow the '&' in the entity reference"

The error is caused by the use of "&" operator in "if" sentence.
However, if I used the "|" operator, rewriting like this, the page works fine:
if (!logVal.equals(pasVal) | (!logVal!=null)))


The question is: What is the AND operator? That's "&" in Java, but it doesn't works in the script
Tank you in advance!!!

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-09-03 20:18:32 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

Hi,

this is a problem with escaping the ampersand, which has a special meaning in XML. You'll have to use a CDATA-Section like the following:

<zscript><![CDATA[
... here you can use & as you like...
]]></zscript>

I would recommend to always use a CDATA-Section within ZScript.

HTH, Maik

link publish delete flag offensive edit

answered 2008-09-03 20:26:50 +0800

zuzsso gravatar image zuzsso
48

updated 2008-09-04 01:53:53 +0800

Thankyou very much mjablonski. I'll try as you recommend. I tried the && operator and works fine. Regards!!!
PD: It worked because I separated the code from the view, into a page called check.zul. This page was referenced using the src attribute for the zscript tag

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-09-03 15:10:51 +0800

Seen: 491 times

Last updated: Sep 03 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More