Cast the User to TurbineUser or BaseObject and call getPrimaryKey() 

-----Original Message-----
From: Jim Knoll [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 10:06 PM
To: [EMAIL PROTECTED]
Subject: Getting User Id


Hello,

    I have followed the instructions in the Extend User How To.
    Now I am trying to use the Turbine User Id as a foreign 
    key in my application.  This is what I have tried:

    public void doBuildTemplate( RunData data, Context context )
    {
        TurbineUser sru = (TurbineUser) data.getUser();
        ObjectKey key = sru.getPrimaryKey();
        java.math.BigDecimal key_val = (java.math.BigDecimal) key.getValue();
        int user_id = key_val.intValue();
        Vector v = getEntries(0);
                                         
        context.put("entries", v); 
    } 

    getEntries queries the database for records matching the User Id.

    I get a ClassCastException when I try to cast the value returned by
    data.getUser() to TurbineUser.  Could anybody tell me what I am doing
    wrong?

Thanks,

Jim

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to