Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Child question +  illegal start of expression error

Thread view: 
cliveswan@yahoo.co.uk - 16 Apr 2007 21:51 GMT
I have a form with a question and child questions

eg q1 program - Yes/no
    q2 web; desktop
    q3 java; .net; #C

My form is:
Q6a: Waterproblem (yes/NO)
Q6b: Current - radiobutton (curent, 1-5 years)
Q6c: Location Home (yes/No); Garden (Yes/No); common (yes/no)

If user selects Q6a = Yes (1)
....
Q6c  Home (0/1); Garden (0/1); common (0/1)

I want to check, if user selects Yes for Q6a, then they need
select 1 from Q6c.
If they don't select one choice, want to have a simple error warning.

Yes = 1   No = 0

The code shows an illegal start of expression error????

if( page8.getWasteWaterProblem() == 1 ) ||
(getWasteWaterLocationProblemHome() == 0) ||
(getWasteWaterLocationProblemGarden() == 0) ||
(getWasteWaterLocationProblemCommonArea() ==0){

validationResultPage8.addWarning("WasteWaterProlemHome", "warning for
WasteWaterProlemHome from type 6c");
}
Eric Sosman - 16 Apr 2007 22:07 GMT
cliveswan@yahoo.co.uk wrote On 04/16/07 16:51,:
> I have a form with a question and child questions
>
[quoted text clipped - 20 lines]
>
> if( page8.getWasteWaterProblem() == 1 ) ||
                                       ^

   The test portion of the `if' statement ends at
this parenthesis.  What follows should be an executable
statement, but what actually follows is `||'.  `||' is
not valid as the start of an expression or statement.

   Possible cure: Delete that parenthesis.  Alternative
cure: Insert an opening parenthesis just before `page8'.
Either way, you will also need to add another closing
parenthesis just before the `}' below.

   Still another cure: Get rid of all the parentheses
except the one right after `if', the one right before
`}', and the pairs after each method call.

> (getWasteWaterLocationProblemHome() == 0) ||
> (getWasteWaterLocationProblemGarden() == 0) ||
[quoted text clipped - 3 lines]
> WasteWaterProlemHome from type 6c");
> }

   Note, too, that the logic is flawed: The test (after
correction) will produce a validation warning if the
first box is checked or if any of the others is unchecked.
From your description, I doubt that's what you want.

Signature

Eric.Sosman@sun.com

Lew - 17 Apr 2007 00:16 GMT
>> I have a form with a question and child questions

cliveswan@yahoo.co.uk wrote On 04/16/07 16:51,:
>     Note, too, that the logic is flawed: The test (after
> correction) will produce a validation warning if the
> first box is checked or if any of the others is unchecked.
> From your description, I doubt that's what you want.

Also note that multi-posting causes people to answer your questions without
knowledge of each other's answers and is very rude, as it makes those of us
who try to help feel that you have taken advantage of us and caused us to
waste our time.

Please do not multi-post.

> Lew wrote:
>> Clive wrote:
[quoted text clipped - 4 lines]
>> You're not allowed to put the OR operator (||) after the closing
>> parenthesis of the condition.

Signature

Lew

cliveswan@yahoo.co.uk - 17 Apr 2007 09:36 GMT
Hi,

This is a different question from the previous.
It is looking at validating a question & connected child question
in a row!!!

I tried to write a bit of code THAT does not work.
Trying to understand why!!

Clive

>the same question taken advantage of us and caused us to
> waste our time.
>
> Please do not multi-post.
cliveswan@yahoo.co.uk - 17 Apr 2007 10:19 GMT
Hi eric & Lew,

Am I still not getting the 'logic'

Trying to say:

if a = 1 and ( (b + c + d ) = 0 ){
Then throw a warning
}

if( page8.getWasteWaterProblem() == 1 ) &&
(    ( (page8.getWasteWaterLocationProblemHome() ) +
(page8.getWasteWaterLocationProblemGarden() )
        + (page8.getWasteWaterLocationProblemCommonArea()) == 0)    ) {
        validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for Q6c");
        }
This still says "illegal start of expression"??????
I do not understand why.

Cheers

Clive
Clive - 17 Apr 2007 10:26 GMT
> >> I have a form with a question and child questions
>
[quoted text clipped - 9 lines]
> who try to help feel that you have taken advantage of us and caused us to
> waste our time.

I popsted it here by mistake.

You are not able to delete a question, posted by mistake.

Clive

> Please do not multi-post.
>
[quoted text clipped - 9 lines]
> --
> Lew
Clive - 17 Apr 2007 10:29 GMT
> >> I have a form with a question and child questions
>
[quoted text clipped - 9 lines]
> who try to help feel that you have taken advantage of us and caused us to
> waste our time.

It would be useful, if the list had an option to delte questions, sent
to the wrong
newsgroup!!   This was meant for developers NOT database

> Please do not multi-post.
>
[quoted text clipped - 9 lines]
> --
> Lew
cliveswan@yahoo.co.uk - 17 Apr 2007 11:42 GMT
> >> I have a form with a question and child questions
>
[quoted text clipped - 9 lines]
> who try to help feel that you have taken advantage of us and caused us to
> waste our time.

I FINALLY saw each argument must be within (  ). That went over my
head.

This ran without any errors.

BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
1) )
then throw warning?????

Cheers

Clive

if (    ( page8.getWasteWaterLocationProblemHome() == 0 &&
page8.getWasteWaterLocationProblemGarden() == 0 &&
        page8.getWasteWaterLocationProblemCommonArea() == 0) &&
( page8.getWasteWaterProblem() == 1)  ) {

        validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for WasteWaterProlemHome from type 6c");
        }

> Please do not multi-post.
>
[quoted text clipped - 9 lines]
> --
> Lew
cliveswan@yahoo.co.uk - 17 Apr 2007 11:45 GMT
I FINALLY saw each argument must be within ( (  ) && ( )  ). That went
over my head.

This ran without any errors.

BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
1) )
then throw warning?????

Cheers
Clive

if (    ( page8.getWasteWaterLocationProblemHome() == 0 &&
page8.getWasteWaterLocationProblemGarden() == 0 &&
               page8.getWasteWaterLocationProblemCommonArea() == 0)
&&
( page8.getWasteWaterProblem() == 1)  ) {


validationResultPage8.addWarning("WasteWaterProlemHome", "warning
for WasteWaterProlemHome from type 6c");
               }
Lew - 17 Apr 2007 12:59 GMT
> I FINALLY saw each argument must be within ( (  ) && ( )  ). That went
> over my head.

<http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html>

They aren't arguments, they're conditions.

> This ran without any errors.
>
> BUT does it actually do what is says: ( (a=0 + b=0 + c=0) and (d =
> 1) )
> then throw warning?????
(You only need one question mark to signify a question.)

I am confused.  It ran without errors or it threw a warning?

To answer your question, code always does what it says.  It just might not do
what you think.

> if (    ( page8.getWasteWaterLocationProblemHome() == 0 &&
> page8.getWasteWaterLocationProblemGarden() == 0 &&
[quoted text clipped - 6 lines]
> for WasteWaterProlemHome from type 6c");
>                 }

If you have a question, please provide an SSCCE and copy-and-paste (do not
describe) the error message, and ask the question.

You should also follow standard indentation conventions; your code snippet is
not formatted for readability.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.