How to pass enum values as method parameters from a client main method to the session bean

Please see entity bean and client below.  The problems is with the client method call.  How can I pass the parameter .  This is how I am doing it: customer_1.setCustomerType(CustomerType.REGISTERED);

Thanks

Sunse

package titan.domain;

import javax.persistence.*;

import com.sun.imageio.plugins.jpeg.JPEG;

import java.io.Serializable;
import java.util.Date;

enum CustomerType{ UNREGISTERED, REGISTERED, BIG_SPENDAH}

@Entity
@Table(name="CUSTOMER_TABLE")
public class Customer implements Serializable
{
      private int id;
      private String lastName;
      private String firstName;
      private CustomerType customerType;
      private Date timeCreated = new Date();
      private JPEG picture;
      
      @Id
      @GeneratedValue
      @Column(name="CUST_ID")
      public int getId()
      {
            return id;            
      }
      
      public void setId(int pk)
      {
            id = pk;
      }
      
      public String getLastName()
      {
            return lastName;
      }
      
      public void setLastName(String lastName)
      {
            this.lastName = lastName;
      }
      
      public String getFirstName()
      {
            return firstName;
      }
      
      public void setFirstName(String firstname)
      {
            this.firstName = firstName;
      }
      
      @Enumerated(EnumType.STRING)
      public CustomerType getCustomerType()
      {
            return customerType;
      }
       public void setCustomerType(CustomerType type)
       {
             customerType = type;
       }
}
      
package titan.clients;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import titan.domain.Cabin;
import titan.domain.Customer;
import titan.travelagent.TravelAgentBean;
import titan.travelagent.TravelAgentRemote;



public class Client_4
{
      public enum CustomerType{ UNREGISTERED, REGISTERED, BIG_SPENDAH}
    public static void main(String [] args) {
          
        try  {
            Context jndiContext = getInitialContext();
            Object ref = jndiContext.lookup("TravelAgentBean/remote");
            TravelAgentRemote dao = (TravelAgentRemote)ref;
           
            Customer customer_1 = new Customer();
            customer_1.setId(1);
            customer_1.setLastName("Smith");
            customer_1.setFirstName("Marc");
            customer_1.setCustomerType(CustomerType.REGISTERED);
           
           
        }
        catch (javax.naming.NamingException ne) {
                              ne.printStackTrace();
                        }
    }

        public static Context getInitialContext( )
                        throws javax.naming.NamingException {
                              Properties p = new Properties();
                              p.put(Context.INITIAL_CONTEXT_FACTORY,
                                    "org.jnp.interfaces.NamingContextFactory");
                              p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                              p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                              return new InitialContext(p);
            }
}
sunseApplication DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
This is how I am doing it: customer_1.setCustomerType(CustomerType.REGISTERED);
That would be the way to do it.

Why, are you having problems with this?
sunseApplication DesignerAuthor Commented:
I do not know.  It appears highlighted red in eclipse.  I will run the client with ant and jboss to look at the output.  Were you able to reproduce an error?
mccarlIT Business Systems Analyst / Software DeveloperCommented:
It appears highlighted red in eclipse.
And if you mouseover the red highlighted section, does it give you an error message?
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

sunseApplication DesignerAuthor Commented:
Yes, The method setCustomerType(CustomerType) in the type Customer is not applicable for the arguments(Client_4.CustomerType)
CEHJCommented:
customer_1.setCustomerType(Customer.CustomerType.REGISTERED);

Open in new window

is what you want. Don't redefine it in Client4
sunseApplication DesignerAuthor Commented:
Thank you CEHJ,  I implemented your solution above; but now I get Customer cannot be resolved or is not a field.
CEHJCommented:
Yes, the enum is still entangled. I would be inclined to place the (public) enum in its own compilation unit, say in package titan.domain. Then import titan.domain.CustomerType and:

 
          Customer customer_1 = new Customer();
            customer_1.setId(1);
            customer_1.setLastName("Smith");
            customer_1.setFirstName("Marc");
            customer_1.setCustomerType(CustomerType.REGISTERED);

Open in new window


That way you will be able to vary the enum independently and using it will be smoother

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunseApplication DesignerAuthor Commented:
Thanks CEHJ.  It works!
CEHJCommented:
:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.