Hi Guys,

really sorry about my lapse here in providing the right info and I kow it must 
be frustrating.

I played hockey last night. So i got pre-empted.

Ok I am back on the tarp.

I will try to get the stack trace for you... but none is being produced in the 
console... and its an NPE ? I am wondering about that.

My Year.Java class... yes its a pojo... I dont understand why that might be a 
crime... maybe for Date stuff... but its fairly remote and implemented 
independent.

Ok back to he real stuff...

Ok I am seeinfg the source code for this has tajken on some changes,,,

Here is my blip

    @Inject
    @Property
    private TypeCoercer typeCoercer;

    @Property
    private SelectModel yearSelectModel;
    @Property
    @Persist(PersistenceConstants.FLASH)
    private Year year;    

    @Inject
    private PropertyAccess adapter;    
    @Inject
    private ValueEncoderSource valueEncoderSource;
        
    @SetupRender
    void setupRender() {

        SelectModelFactory selectModelFactory = new 
SelectModelFactoryImpl(adapter, valueEncoderSource);
        grid.reset();

        years = new 
ArrayList(TynamoUTIL.loadCollection(hibernatePersistenceService, Year.class));
        yearSelectModel = selectModelFactory.create(years, "toString");

selectModelFactory is failing because my usage of SelectModelFactoryImpl fails 
to operate. So I told eclipse to connect to the source code downloaded to my 
local repo... and sure enough.. in the debugger I see this...

            final PropertyAdapter propertyAdapter = 
classPropertyAdapter.getPropertyAdapter(labelProperty);

            final ValueEncoder encoder = 
this.valueEncoderSource.getValueEncoder(propertyAdapter.getType());


my propertyAdapter is null and any subsequent attempts to use it fail with NPE

But I need to distinguish some kind of label property ? in my year class to 
this thing ? So it can create the proper OPTIONS eFrastructure ?

I figured the Year.toString() method would suffice for this.

Here is my Year.JAVA again

Not sure what to think... tapestry is failing when I tell it to use 
Year.toString()

What should I do ?

@Entity
@ClassDescriptor(hasCyclicRelationships = true, nonVisual = false)
public class Year implements Cloneable, Serializable {
    private static final Log log = LogFactory.getLog(Year.class);

    private Integer id = null;

    private Integer yearStart = new Integer("0");

    private Integer yearEnd = new Integer("0");
    
    private League league = null;

    private Long created = new Long(GregorianCalendar.getInstance()
            .getTimeInMillis());

    private Long accessed = new Long(GregorianCalendar.getInstance()
            .getTimeInMillis());

    /**
     * CTOR
     */

    public Year() {
    }

    public Year(Year dto) {
        try {
            BeanUtils.copyProperties(this, dto);
        } catch (Exception e) {
            log.error(e.toString());
            e.printStackTrace();
        }
    }

    /**
     * Accessor for id
     * 
     * @return Integer
     * @hibernate.id generator-class="increment" unsaved-value="-1"
     *               type="java.lang.Integer" unique="true" insert="true"
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @PropertyDescriptor(readOnly = true)
    public Integer getId() {
        return id;
    }

    @PropertyDescriptor
    public Integer getYearStart() {
        return yearStart;
    }

    @PropertyDescriptor
    public Integer getYearEnd() {
        return yearEnd;
    }

    @ManyToOne
    public League getLeague() {
        return league;
    }

    @PropertyDescriptor(nonVisual = true, searchable = false)
    public Long getCreated() {
        return created;
    }

    @PropertyDescriptor(nonVisual = true, searchable = false)
    public Long getAccessed() {
        return accessed;
    }

    @Transient
    @PropertyDescriptor(nonVisual = true, searchable = false)
    public String getCreatedAsString() {
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(created.longValue());
        return DatePattern.sdf.format(cal.getTime());
    }

    @Transient
    @PropertyDescriptor(nonVisual = true, searchable = false)
    public String getAccessedAsString() {
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(accessed.longValue());
        return DatePattern.sdf.format(cal.getTime());
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setYearStart(Integer yearStart) {
        this.yearStart = yearStart;
    }

    public void setYearEnd(Integer yearEnd) {
        this.yearEnd = yearEnd;
    }

    public void setLeague(League league) {
        this.league = league;
    }

    @Transient
    @PropertyDescriptor(nonVisual = true, searchable = false)
    public void setCreatedAsString(String value) throws Exception {
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(DatePattern.sdf.parse(value).getTime());
        this.created = new Long(cal.getTimeInMillis());
    }

    @Transient
    @PropertyDescriptor(nonVisual = true, searchable = false)
    public void setAccessedAsString(String value) throws Exception {
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(DatePattern.sdf.parse(value).getTime());
        this.accessed = new Long(cal.getTimeInMillis());
    }

    public void setAccessed(Long accessed) {
        this.accessed = accessed;
    }

    public void setCreated(Long created) {
        this.created = created;
    }

    @Override
    public int hashCode() {
        return (getId() != null ? getId().hashCode() : 0);
    }

    @Override
    public Year clone() {
        return new Year(this);
    }

    /**
     * equals and hashCode need to be hammered out for hibernate to work
     * properly
     * 
     * Check the matrix summary for best practices at
     * http://www.hibernate.org/109.html
     */
    @Override
    public boolean equals(Object rhs) {
        if (this == rhs)
            return true; // instance equality
        if (rhs == null || getClass() != rhs.getClass())
            return false; // null/class equality

        final Year castedObject = (Year) rhs;

        return !(getId() != null ? !getId().equals(castedObject.getId())
                : castedObject.getId() != null);
    }

    public String toString() {
        return getYearStart().toString() + "/" + getYearEnd().toString();
    }
}
                                          

Reply via email to