Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need help I have set a boolean in form .. I need to check if boolean is true in another class

Posted on 2011-10-01
42
203 Views
Last Modified: 2012-06-22
Hi ,

I have to check if a user is admin or a analyst ... if a user is analyst I have to return some value

I already did role checking in my action and form classes .I also have following getters and setters

getIsAnalyst()   method which returns isAnalyst  (which is a boolean value)  and setIsAnalyst  method


I have an another helper class , which returns some ID ... I want to check in that helper class wether isAnalyst or not

I tried

if(form.getisAnalyst)
{
return " " ;

}

else

return " "


but form(which is object of form class)I get error "form" cannot be resolved , I tried creating object for my form class in that helper class , i am not sure If I am doing it right .Is there any other way of doing it or anybody has a good solution to it ...please help !!!!

0
Comment
Question by:questjava
  • 21
  • 21
42 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36897611
you need to have form defined (as an instance of tyoe/class form) in order for compiler to be able to resolve it
0
 

Author Comment

by:questjava
ID: 36897616
Form  form = new Form();

I did this

I aslo imported

import com.Form;
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897618
Before you could use it further in the code you should have somewhere within the scope declaraton:
Form form;
Or something like that
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:questjava
ID: 36897623
I am getting now error saying import cannot be resolved....
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897625
Also getIsAnalyst is a mthod - it shouild be followed by parentheses()
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897629
That's another story - where are you suposed to get this Form class ?
0
 

Author Comment

by:questjava
ID: 36897631
yes it is followed by paranthesis...

I am trying to import that class

create an object od that class so that I can use that get method ...but I am getting import cannot be resolved ..therefore its instance also cannot be resolved..I dont know what to do
0
 

Author Comment

by:questjava
ID: 36897634
Form class and Helper class are not in same package
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897635
Do you have some library where you are supposed to have class Form or you wrote this class yourself ?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897640
Then you need to import Form correctly
What is the name of the package?
0
 

Author Comment

by:questjava
ID: 36897643
This class is written by me but its in some other package like com.form;

and helper class is in another package like com.helper;
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897645
Do you have access to the java code of Form
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897649
Look at what is written in package command in the first line of Form source
0
 

Author Comment

by:questjava
ID: 36897650
To access programmatically first I have to import that package and create an instance/object to that class ..


I have manual access also to that form , I can view and edit it as well
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897652
If it says
package com.form;

Public class Form {
}

Then in the import of helper you shoul write

Import com.form.Form;
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897653
Of course import and public - all with lower case
0
 

Author Comment

by:questjava
ID: 36897659
I did import a.b.c.com.Form;

it says a.b.c cannot be resolved
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897666
What is a.b.c ?
0
 

Author Comment

by:questjava
ID: 36897668
its in package a.b.c.com.Form;

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897673
Do you have your classes placed ion correct folder structurte?
Are yu using IDE or command line
0
 

Author Comment

by:questjava
ID: 36897677
IDE ...and correct folder struture
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897689
Perhaps the Form has some other compile errors, so it has not been compiled either so it cannot resolve it here
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897695
If you can post yoir codes - post them - ikll be at my computer in half an hour - I'll check it
0
 

Author Comment

by:questjava
ID: 36897707
Forms compile fine , only problem is unable to import that huge package
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897718
It cannot be becuase of huge _- post the begiining lines of both classes
0
 

Author Comment

by:questjava
ID: 36897726
you want the package lines ?
and import lines?
0
 

Author Comment

by:questjava
ID: 36897729
I justr checked the helper class is already imported in form class , so can I not import form class into helper class   ?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897738
It is rarely a.b.c.com.
It is usually com.a.b.c...
0
 

Author Comment

by:questjava
ID: 36897744
yes its com.a.b.c.Form;
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897748
Post the headers of both Form and Handler up to the. Opening class line
0
 

Author Comment

by:questjava
ID: 36897750
its com.a.b.c.k.l.helper;
0
 

Author Comment

by:questjava
ID: 36897752
com.a.b.c remains same for both
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897758
In the import you should name up to the class name itself
In package statement you declare the package and not include the actual classname
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36897766
Post the headers - I'll look at them when I reach muy computer in 20 min
0
 

Author Comment

by:questjava
ID: 36897767
I understand but  I am going upto the class name but still error of com.a.b.c remains same "cannot be resolved"
0
 

Author Comment

by:questjava
ID: 36897768
ok
0
 

Author Comment

by:questjava
ID: 36897791
package for  helper

package com.abc.tip.util;
 
class name : Helper

package for form

com.abc.tip.app.form.maintenance;

Class name : Form

Now when in helper I try to import

impport com.abc.tip.app.form.maintenance.Form;


I get com.abc.tip.app cannot be resolved
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36897827
go into file system and check if you really have this Form.class sitting in there
and check syntax of all folder names, cases (all lower), etc.

There is some misprint - if you Form was compiled and Form.class file is present in com/abc/tip/app/form/maintenance
it is impossible that compiler cannot resolve it
0
 

Author Comment

by:questjava
ID: 36897831
I will check on it
0
 

Author Comment

by:questjava
ID: 36921082
Well I checked it , the problem was RSA IDE was not allowing to import since it would create a circular dependence as one of them was already pointing to other , i.e a points to b , but if try to use "a in b" , i have to do b points to a ..which was the problem
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36921137

What is RSA IDE ?

I think it happens in most of the priojects and never causes any issues.
If you use different packages in the project it always happens this way - don't understand why iit does not know how to deal with it
0
 

Author Comment

by:questjava
ID: 36921162
rational software architect -- but I actually have solved it with another approach .. I appreciate your help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question