tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lindsay Steele" <lste...@iinet.net.au>
Subject RE: PropertySelection
Date Thu, 02 Sep 2004 08:51:30 GMT
Interesting that is how I started ... And kept on getting null pointer
errors so then tried a different track.

I have this in my page specification

<property-specification name="departmentItem"
type="pabxreports.data.Department" persistent="yes"/>
<property-specification name="departmentGroupSelectionModel"
type="pabxreports.models.DepartmentGroupSelectionModel"
persistent="yes"/>   
    
 In the page class I have ....

    public abstract Department getDepartmentItem();
    public abstract void setDepartmentItem(Department value);


I then load them into the property selection model (using cayenne) ...

    private void loadDepartmentsData(){
        // check if it exists, if not init
        if(getDepartmentGroupSelectionModel() == null) {
             
             SelectQuery query = new SelectQuery(Department.class);
                       
            IPropertySelectionModel p = (DepartmentGroupSelectionModel)
                 new
DepartmentGroupSelectionModel(getVisitDataContext().performQuery(query))
;
 
setDepartmentGroupSelectionModel((DepartmentGroupSelectionModel) p);
        }
        
    }

 A list of departments are passed to the propertySelectionModel as the
pages is created.  They display correctly when the page is displayed.

 Where I am having trouble is trying to bring back the currently
selected Department object.  Maybe that is why I moved onto get
something back 
>From the model itself. 

 I keep on getting null pointer errors every time I try to access it.

 I was using the following to access it.

		String currentDepartmentName = "ALL";
   		Department dep = getDepartmentItem();
		currentDepartmentName = dep.getDepartmentName();

 What I have now discovered is that it only null pointers the first time
the page loads .... But after that it works ok.

		String currentDepartmentName = "ALL";
		Department dep = getDepartmentItem();
		if (dep != null) currentDepartmentName =
dep.getDepartmentName();

  This seems to work .... Might just leave it at that unless anyone has
any better ideas.

  Thanks for letting me know what I was doing in the first place was ok.

   Lindsay



-----Original Message-----
From: Jon Newton [mailto:jon@SCANSOFTWARE.COM] 
Sent: Wednesday, 1 September 2004 10:26 PM
To: Tapestry users
Subject: RE: PropertySelection


Make a page property 

<property-specification name="selectedValue" type="java.lang.Object"/> 

And set your PropertySelection value parameter to this property.. 

Then in your page class, use getSelectedValue()

Jon 

> -----Original Message-----
> From: Lindsay Steele [mailto:lsteele@iinet.net.au]
> Sent: Wednesday, September 01, 2004 3:37 AM
> To: 'Tapestry users'
> Subject: PropertySelection
> 
> I am having trouble working out how to access the values of the
> currently selected item in a property selection model from code.   
> 
> I have basically implemented it the same as the examples
> where I pass a object with the relevant values to the 
> propertySelectionModel.  
> 
> I want to access the values of the currently selected item in
> the propertyselection model,  I can see the examples doing it 
> in html but not from the class attached to the page.
> 
> Does anyone have any examples of doing this ???
> 
>   Thanks,
> 
>      Lindsay
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Mime
View raw message