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
200 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now