[Logo]
Forums Register Login
How do I add a string variable to list?
I cant get my string variable to go into list. anyone able to tell how i can do it?
heres my code i am having problems with:

any help is appericated!

This is what you asked. But I sense that is not what you want. Perhaps explain your problem again trying to make it a bit clearer this time.
 

Tim Cooke wrote:
This is what you asked. But I sense that is not what you want. Perhaps explain your problem again trying to make it a bit clearer this time.

userName is variable that definies what is written to csv file.
Exactly what part of it isn't doing what you expect?
 

Tim Cooke wrote:Exactly what part of it isn't doing what you expect?

It does not search from list the userName variable
Let's start at the beginning:

- Does userName contain a string? Or is it null?
- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
- What goes on in singleEmployeecsv.csv(list); Does it do what you expect?
 

Tim Cooke wrote:Let's start at the beginning:

- Does userName contain a string? Or is it null?
- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
- What goes on in singleEmployeecsv.csv(list); Does it do what you expect?

username should come from html: <a  input class="btn2"  id="employee"  rel="nofollow">DL csv, username is variable that by program gets info from list. to list goes employee info that then goes into csv file.
 

jhonson berens wrote:

Tim Cooke wrote:Let's start at the beginning:

- Does userName contain a string? Or is it null?
- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
- What goes on in singleEmployeecsv.csv(list); Does it do what you expect?

username should come from html: <a  input class="btn2"  id="employee"  rel="nofollow">DL csv, username is variable that by program gets info from list. to list goes employee info that then goes into csv file.


oops, heres complete html code  that cut off:
 

jhonson berens wrote:

jhonson berens wrote:

Tim Cooke wrote:Let's start at the beginning:

- Does userName contain a string? Or is it null?
- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
- What goes on in singleEmployeecsv.csv(list); Does it do what you expect?

username should come from html: <a  input class="btn2"  id="employee"  rel="nofollow">DL csv</a>, username is variable that by program gets info from list. to list goes employee info that then goes into csv file.


oops, heres complete html code  that cut off:


it keeps disappearing, but here:
(1 like)
Does that string value make it into the getEmployee method? Perhaps put some System.out.println(); statements in there to print the value to the console as a debug technique.
 

Tim Cooke wrote:Does that string value make it into the getEmployee method? Perhaps put some System.out.println(); statements in there to print the value to the console as a debug technique.

it prints usernames as its supposed, now i need it to get only that username's data
Next step:

- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
 

Tim Cooke wrote:Next step:

- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?

it doesnt return anything
It has to return something

- null
- Empty list
- Populated list

Unless an exception it thrown. Is as exception thrown?
 

Tim Cooke wrote:It has to return something

- null
- Empty list
- Populated list

Unless an exception it thrown. Is as exception thrown?

it is
What is? The clearer the information you provide, the easier it is to help.
 

Tim Cooke wrote:What is? The clearer the information you provide, the easier it is to help.

null
 

jhonson berens wrote:

Tim Cooke wrote:What is? The clearer the information you provide, the easier it is to help.

null

i mean exception is thrown
Again, more information is useful.

- What kind of exception?
- Where is it being thrown?

Try to work this little bit through yourself and find out exactly where the exception is originating from. Perhaps employeeService is null? Why? Perhaps getEmployeeByUserName() throws and exception within it? Dig in and find it.
 

Tim Cooke wrote:Again, more information is useful.

- What kind of exception?
- Where is it being thrown?

Try to work this little bit through yourself and find out exactly where the exception is originating from. Perhaps employeeService is null? Why? Perhaps getEmployeeByUserName() throws and exception within it? Dig in and find it.

okay i got it working(no more errors), but it doesnt  get values? heres codes:

and part what does not get values from employee:

That's a bit ambiguous, I think. First you said

i got it working(no more errors)



but then you went on to talk about something ("doesnt  get values") as if that was an error. So are you done now, or do you have another question?
You've changed things around a good bit. But that's ok.

employeeService.getEmployeeByUserName(userName) returns a single Employee which makes more sense than a List. But when you run your code does it actually return an Employee? or null?

When you get into the singleEmployeecsv.csv() method, what happens? You say "does not get values" but what exactly does that mean?

This thread has been viewed 340 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 21, 2018 11:15:28.