How to check the boolean variable if it is false!

5 views
Skip to first unread message

sweta

unread,
Feb 15, 2010, 11:41:13 PM2/15/10
to Open Mashup Alliance Interest Group
Hi,

I have script as follows,

<directinvoke endpoint="http://localhost:8086/object/OID:27/action/
checkAvailability(java.lang.String,org.hotel_booking.roomtype.RoomType,org.nakedobjects.applib.value.Date,org.nakedobjects.applib.value.Date)"
method="POST"
arg0="$location"
arg1="$roomType"
arg2="$fromDate"
arg3="$toDate"
username="$userName"
password="$password"
outputvariable="$check_HotelBooking"/>

<foreach variable="iter" items="$check_HotelBooking//
div[@class='nof-action-result']//ul//li/a/@href/string()" >
<display message = "inside the foeach loop of hotelBooking "/>

<!--<display message="The output is = " variable="$iter" />-->

<script type="text/javascript">
<![CDATA[
var r = new String(iter);
var ar = r.split("/");
room_id = ar[2]
]]>
</script>

<!--<display message = "from the script = " variable = "$room_id"/
>-->


<directinvoke endpoint="http://localhost:8086/object/OID:27/
action/
bookRoom(java.lang.String,org.hotel_booking.roomtype.RoomType,org.hotel_booking.room.Room,org.nakedobjects.applib.value.Date,org.nakedobjects.applib.value.Date)"
method="POST"
arg0="$location"
arg1="$roomType"
arg2="$room_id"
arg3="$fromDate"
arg4="$toDate"
username="$userName" password="$password"
outputvariable="$bookRoom"/>
<!--<display message="After 2nd DirectInvoke" variable="$result"/
>-->
<assign fromexpr="$bookRoom//a[@class='nof-action-result']//
@href" tovariable="$resultRoom"/>
<display message = "id for Room = " variable = "$resultRoom"/>

<if condition ="$resultRoom != ''">
<display message = "if condition --- hotelBooking "/>
<assign fromvariable="$flag" tovariable="$HotelBookingflag"/>
<display message="the HotelBookingflag = "
variable="$HotelBookingflag"/>
<break/>
</if>
<!--<else>
</else>-->
</foreach>

<display message="Hurray! i am out of HotelBooking"
variable="$HotelBookingflag"/>

<if condition ="$HotelBookingflag = false">
<display message="The hotel booking flag is false"/>
</if>


In this script.. when i am displaying the $HotelBookingflag. It is
giving me false, but then when i am checking the flag in <if
condition> it is not displaying the message. Why is it so? I am
checking it in a wrong way it seems, but it is not giving me any
syntax error. Please help me understand this.


Thanks in advance,
Sweta

nzbluefish

unread,
Feb 16, 2010, 4:46:00 PM2/16/10
to Open Mashup Alliance Interest Group
Hi Sweta,

I'm assuming that you know that the value of $HotelBookingflag is
actually a boolean value, which if that is the case, you need to
change the condition attribute on the if statement to read:

condition="$HotelBookingflag = false()"

so that you are calling the Xpath function false. It will return a
boolean value of FALSE which will then be compared to the value in
$HotelBookingflag.

Here's a small emml script that shows how this works. Hope this helps.

Cheers, Innes

<output name="$HotelBookingflag" type="boolean" />

<variables>
<variable name="flag" type="boolean" default="false" />
<variable name="hotelBookingFlag" type="boolean" default="true"/>

</variables>

<display message="$flag=" variable="flag" />
<display message="$hotelBookingFlag=" variable="hotelBookingFlag" /
>

<if condition="$flag = false()">
<display message="flag is false ..." />
</if>

<assign fromvariable="$flag" outputvariable="$HotelBookingflag" />
<display message=" ******* script output ******* " />

Executing the script...
$flag= false
$hotelBookingFlag= true
flag is false ... ******* script output *******
false

On Feb 16, 5:41 pm, sweta <desai3sw...@gmail.com> wrote:
> Hi,
>
> I have script as follows,
>
> <directinvoke endpoint="http://localhost:8086/object/OID:27/action/

> checkAvailability(java.lang.String,org.hotel_booking.roomtype.RoomType,org.­nakedobjects.applib.value.Date,org.nakedobjects.applib.value.Date)"


>                                         method="POST"
>                                         arg0="$location"
>                                         arg1="$roomType"
>                                         arg2="$fromDate"
>                                         arg3="$toDate"
>                                         username="$userName"
>                                         password="$password"
>                                         outputvariable="$check_HotelBooking"/>
>
>                                 <foreach variable="iter" items="$check_HotelBooking//
> div[@class='nof-action-result']//ul//li/a/@href/string()" >
>                                 <display message = "inside the foeach loop of hotelBooking "/>
>
>                                         <!--<display message="The output is = " variable="$iter" />-->
>
>                                         <script type="text/javascript">
>                                         <![CDATA[
>                                                 var r = new String(iter);
>                                                         var ar = r.split("/");
>                                                         room_id = ar[2]
>                                         ]]>
>                                         </script>
>
>                                         <!--<display message = "from the script = " variable = "$room_id"/
>
> >-->
>
>                                         <directinvoke endpoint="http://localhost:8086/object/OID:27/
> action/

> bookRoom(java.lang.String,org.hotel_booking.roomtype.RoomType,org.hotel_boo­king.room.Room,org.nakedobjects.applib.value.Date,org.nakedobjects.applib.v­alue.Date)"

nzbluefish

unread,
Feb 16, 2010, 4:00:38 PM2/16/10
to Open Mashup Alliance Interest Group
Hi Sweta,

I'm assuming that you know that the variable $HotelBookingflag
actually contains a boolean value, so if this is the case, what I
think you need to do is change the condition attribute in the if
statement to read:

condition="$HotelBookingflag = false()"

so that you are actually calling the Xpath function false to return a
boolean FALSE value which is then compared to the value contained in
the $HotelBookingflag.

I've attached a small emml script below as an example of this for you:

Cheers, Innes

<output name="$HotelBookingflag" type="boolean" />

<variables>
<variable name="flag" type="boolean" default="false" />
<variable name="hotelBookingFlag" type="boolean" default="true"/>

</variables>

<display message="$flag=" variable="flag" />

<display message="$hotelBookingFlag" variable="hotelBookingFlag" />

<if condition="$flag = false()">
<display message="flag is false ..." />
</if>

<assign fromvariable="$flag" outputvariable="$HotelBookingflag" />


----- what it outputs -----

Executing the script...
$flag= false

$hotelBookingFlag true
flag is false ...
false

nzbluefish

unread,
Feb 16, 2010, 4:09:29 PM2/16/10
to Open Mashup Alliance Interest Group
Hi Sweta,

I'm assuming that you know that the value of $HotelBookingflag is


actually a boolean value, which if that is the case, you need to

change the condition attribute on the if statement to read:

condition="$HotelBookingflag = false()"

so that you are calling the Xpath function false. It will return a


boolean value of FALSE which will then be compared to the value in
$HotelBookingflag.

Here's a small emml script that shows how this works. Hope this helps.

Cheers, Innes

<output name="$HotelBookingflag" type="boolean" />

<variables>
<variable name="flag" type="boolean" default="false" />
<variable name="hotelBookingFlag" type="boolean" default="true"/>

</variables>

<display message="$flag=" variable="flag" />

<display message="$hotelBookingFlag=" variable="hotelBookingFlag" /
>

<if condition="$flag = false()">
<display message="flag is false ..." />
</if>

<assign fromvariable="$flag" outputvariable="$HotelBookingflag" />

<display message=" ******* script output ******* " />

Executing the script...
$flag= false

nzbluefish

unread,
Feb 16, 2010, 4:12:52 PM2/16/10
to Open Mashup Alliance Interest Group

nzbluefish

unread,
Feb 16, 2010, 4:17:35 PM2/16/10
to Open Mashup Alliance Interest Group

sweta

unread,
Feb 18, 2010, 7:55:24 AM2/18/10
to Open Mashup Alliance Interest Group
Thanks a lot nzbluefish,

Its now checking the condition. Actually i am not much aware about the
XPath expression and functions facilitated by it.. But I am learning..

Thanks again,
Sweta :-)

Innes Fisher

unread,
Feb 19, 2010, 2:59:03 PM2/19/10
to open-mashu...@googlegroups.com
Hi Sweta,

You're very welcome. You'll find the XPath functions very helpful if you
start doing any complex emml scripts.

Here's a link to the Functions and Operators that I use all the time. You'll
especially want to check out the String and Date functions.

http://www.w3.org/TR/xpath-functions/

Cheers, Innes

Thanks a lot nzbluefish,

Thanks again,
Sweta :-)
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.733 / Virus Database: 271.1.1/2697 - Release Date: 02/19/10
20:34:00

Reply all
Reply to author
Forward
0 new messages