Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java Bean question

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I access another field in a Getter routine. What I want to do is to look at other fields (in the same bean) so I can calculate the value of the getLiabilityType routine.
I've tried lots of different syntaxes and I either get a NULL for the answer or a JBOSS error.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just access any fields in the same object directly. There's nothing special about getter methods that make accessing one field different than another field.

You most likely have a problem somewhere else that causes the result to not be what you expect, but without seeing more of your code it's very hard to say what's wrong.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I try to access the enduser field directly in GetLiabilityType, the field always prints with a value of null - but I know it is not null

 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you call setEnduser() anywhere on the object that you are calling getLiabilityType() on?

If not, then the member variable enduser will have the default value null.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what seems strange and I don't understand how they interrelate. There are two pieces of code named lineOfServiceBean.java - one is on the back end (voxware) and one is on the front end (voxportal). The back end lineOfServiceBean.java displays all the right values in the export routine. I don't have a good handle on what the export routine does.

In the front end (code in previous post of this thread), the fields I need are null.

 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is difficult to tell what has been called as this system is very large and I inherited the code (ie-I didn't write it). I don't understand how the back end and front end systems are talking to each other. My System.out's in the backend show all the data that I'm expecting. My System.out's in the frontend do NOT show all the data which makes me think that it has to do with how the back end and front end transfer data between themselves.

Although I am not seeing the data for the change I am trying to make, the back end is clearly sending data to the front end as the front end is displaying the data on the browser.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your class VoxLineOfService is a JPA entity. Instances of this class can be stored to and retrieved from a database using JPA (the Java Persistence API). The source code you posted of class VoxLineOfService is incomplete and will not compile, because some of the methods are using member variables that are not declared anywhere in the class. The methods unlinkLineOfService, reasignLineOfService and export are using member variables: endUser, billPayer, custodian and owner that are not declared in the class. You'll get compiler errors when you would try to compile this.

Your class LineOfServiceBean is just a regular Java class (a POJO = Plain Old Java Object), that seems to have the same fields as VoxLineOfService.

Probably somewhere in your system, objects of type VoxLineOfService are converted into objects of type LineOfServiceBean. Maybe, somewhere in that code, the original programmer forgot to set some fields, such as the enduser field in LineOfServiceBean.

It's really hard to debug a system with so much code through the forum.

I would use an IDE to automatically find all the places where a LineOfServiceBean is created, and investigate there how those objects are being initialized and where they go.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic