• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How do I add a string variable to list?  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what part of it isn't doing what you expect?
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

It does not search from list the userName variable
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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: 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
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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: 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
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next step:

- Does employeeService.getEmployeeByUserName(userName); return anything? Or null?
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:Next step:

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

it doesnt return anything
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has to return something

- null
- Empty list
- Populated list

Unless an exception it thrown. Is as exception thrown?
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:It has to return something

- null
- Empty list
- Populated list

Unless an exception it thrown. Is as exception thrown?

it is
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is? The clearer the information you provide, the easier it is to help.
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

null
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jhonson berens
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:

 
Sheriff
Posts: 23876
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tim Cooke
Sheriff
Posts: 4573
286
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!