You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by James Hays <ja...@mac.com> on 2003/08/05 18:05:53 UTC
Help with initial selection in PropertySelection
I have implemented PropertySelectionModels for each of my four
PropertySelection components. In two of them, I pass them a list of
strings and in the others, I pass them a list of objects. Rendering of
the components works fine, but I can't get the initial selection to come
up successfully. Below is code for one of my components.
.page ---
<component id="projects" type="PropertySelection">
<binding name="model" expression="projectsModel" />
<binding name="value" expression="visit.level.projectCode" />
</component>
projectsModel --
public class ProjectsPropertySelectionModel implements
IPropertySelectionModel
{
List _projects = null;
public ProjectsPropertySelectionModel(List levels)
{
_projects = levels;
}
public int getOptionCount()
{
return _projects.size();
}
public Object getOption(int i)
{
return _projects.get(i);
}
public String getLabel(int i)
{
return (String) _projects.get(i);
}
public String getValue(int i)
{
return (String) _projects.get(i);
}
public Object translateValue(String string)
{
return string;
}
}
All fields in the visit object are complete and contain the correct data
for the object.
Any thoughts as to why this doesn't work?
Thanks.
James
Re: Help with initial selection in PropertySelection
Posted by James Hays <ja...@mac.com>.
I almost have this working...
Here is what I'm seeing. I have a value set in the visit object which
the PropertySelection component points to. The visit object is set
correctly and fully. From what I can see, on the initial load of the
page, the value is not picked up. On the next visits to the page, the
values are 'remembered' and things work as I believe they are supposed
to. Can anyone offer any more help on this matter?
James
James Hays wrote:
> I have implemented PropertySelectionModels for each of my four
> PropertySelection components. In two of them, I pass them a list of
> strings and in the others, I pass them a list of objects. Rendering
> of the components works fine, but I can't get the initial selection to
> come up successfully. Below is code for one of my components.
>
> .page ---
> <component id="projects" type="PropertySelection">
> <binding name="model" expression="projectsModel" />
> <binding name="value" expression="visit.level.projectCode" />
> </component>
>
> projectsModel --
> public class ProjectsPropertySelectionModel implements
> IPropertySelectionModel
> {
> List _projects = null;
> public ProjectsPropertySelectionModel(List levels)
> {
> _projects = levels;
> }
> public int getOptionCount()
> {
> return _projects.size();
> }
> public Object getOption(int i)
> {
> return _projects.get(i);
> }
> public String getLabel(int i)
> {
> return (String) _projects.get(i);
> }
> public String getValue(int i)
> {
> return (String) _projects.get(i);
> }
> public Object translateValue(String string)
> {
> return string;
> }
> }
>
> All fields in the visit object are complete and contain the correct
> data for the object.
> Any thoughts as to why this doesn't work?
> Thanks.
>
> James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
Re: Help with initial selection in PropertySelection
Posted by James Hays <ja...@mac.com>.
The two models that are objects other than strings, do implement an
equals(). Here is a copy of one. Maybe I have something wrong.
public boolean equals(Object o)
{
if (this == o) return true;
if (!(o instanceof State)) return false;
final State state = (State) o;
if (_standardCode != state._standardCode) return false;
if (_abbreviation != null ?
!_abbreviation.equals(state._abbreviation) : state._abbreviation !=
null) return false;
if (_code != null ? !_code.equals(state._code) : state._code !=
null) return false;
if (_name != null ? !_name.equals(state._name) : state._name !=
null) return false;
return true;
}
James
Howard M. Lewis Ship wrote:
>PropertySelection is reliant on the objects implementing a proper equals().
>
>--
>Howard M. Lewis Ship
>Creator, Tapestry: Java Web Components
>http://jakarta.apache.org/tapestry
>
>
>
>
>
>>-----Original Message-----
>>From: James Hays [mailto:james_hays@mac.com]
>>Sent: Tuesday, August 05, 2003 12:06 PM
>>To: 'Tapestry users'
>>Subject: Help with initial selection in PropertySelection
>>
>>
>>I have implemented PropertySelectionModels for each of my four
>>PropertySelection components. In two of them, I pass them a list of
>>strings and in the others, I pass them a list of objects.
>>Rendering of
>>the components works fine, but I can't get the initial
>>selection to come
>>up successfully. Below is code for one of my components.
>>
>>.page ---
>> <component id="projects" type="PropertySelection">
>> <binding name="model" expression="projectsModel" />
>> <binding name="value" expression="visit.level.projectCode" />
>> </component>
>>
>>projectsModel --
>>public class ProjectsPropertySelectionModel implements
>>IPropertySelectionModel
>> {
>> List _projects = null;
>> public ProjectsPropertySelectionModel(List levels)
>> {
>> _projects = levels;
>> }
>> public int getOptionCount()
>> {
>> return _projects.size();
>> }
>> public Object getOption(int i)
>> {
>> return _projects.get(i);
>> }
>> public String getLabel(int i)
>> {
>> return (String) _projects.get(i);
>> }
>> public String getValue(int i)
>> {
>> return (String) _projects.get(i);
>> }
>> public Object translateValue(String string)
>> {
>> return string;
>> }
>> }
>>
>>All fields in the visit object are complete and contain the
>>correct data
>>for the object.
>>Any thoughts as to why this doesn't work?
>>Thanks.
>>
>>James
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>
RE: Help with initial selection in PropertySelection
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
PropertySelection is reliant on the objects implementing a proper equals().
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
> -----Original Message-----
> From: James Hays [mailto:james_hays@mac.com]
> Sent: Tuesday, August 05, 2003 12:06 PM
> To: 'Tapestry users'
> Subject: Help with initial selection in PropertySelection
>
>
> I have implemented PropertySelectionModels for each of my four
> PropertySelection components. In two of them, I pass them a list of
> strings and in the others, I pass them a list of objects.
> Rendering of
> the components works fine, but I can't get the initial
> selection to come
> up successfully. Below is code for one of my components.
>
> .page ---
> <component id="projects" type="PropertySelection">
> <binding name="model" expression="projectsModel" />
> <binding name="value" expression="visit.level.projectCode" />
> </component>
>
> projectsModel --
> public class ProjectsPropertySelectionModel implements
> IPropertySelectionModel
> {
> List _projects = null;
> public ProjectsPropertySelectionModel(List levels)
> {
> _projects = levels;
> }
> public int getOptionCount()
> {
> return _projects.size();
> }
> public Object getOption(int i)
> {
> return _projects.get(i);
> }
> public String getLabel(int i)
> {
> return (String) _projects.get(i);
> }
> public String getValue(int i)
> {
> return (String) _projects.get(i);
> }
> public Object translateValue(String string)
> {
> return string;
> }
> }
>
> All fields in the visit object are complete and contain the
> correct data
> for the object.
> Any thoughts as to why this doesn't work?
> Thanks.
>
> James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>