Re: IPropertySelectionModel - what they don't write in the documentation

2007-02-12 Thread Murray Collingwood
scott russell  hotmail.com> writes:

> 
> Hi Murray,
> 
> An int to a short is fine, but an Integer doesn't translate to a Short. You 
> just need to change your methods in your selection model to return Short 
> objects, rather than Integer objects.
> 
> regards,
> Scott
> 


Hi Scott

I had tried this approach, changing all of the Integers to Shorts.  So I just
set out to prove you wrongalas, this time I tried it and it worked.  Damn,
wrong again - that's twice this year!

Netx time, Scott, try and make it sound a little more complicated.

Cheers mate
Murray


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



RE: IPropertySelectionModel - what they don't write in the documentation

2007-02-12 Thread scott russell

Hi Murray,

An int to a short is fine, but an Integer doesn't translate to a Short. You 
just need to change your methods in your selection model to return Short 
objects, rather than Integer objects.


regards,
Scott






From: Murray Collingwood <[EMAIL PROTECTED]>
Reply-To: "Tapestry users" 
To: users@tapestry.apache.org
Subject: IPropertySelectionModel - what they don't write in the 
documentation

Date: Fri, 9 Feb 2007 04:39:13 + (UTC)

Hello tapestry experts

The API documentation for IPropertySelectionModel is lacking key 
information.

In particular how the initial value is defined.

What it should say is stuff like:

"To set the initial value of the HTML select element you need to bind a 
value to
this control.  The type of value bound is important  [This is where 
somebody

else needs to take over.]"

I have spent all day trying to initialise a value in my HTML select 
element.  I
had searched through the lists and the web but I didn't find anything like 
what

I was experiencing.  Check out this:

I had a static list of security levels:
private static final String[] textOptions = new String[]{
"(none)",
"Quoting",
"Ordering",
"Shop manager",
"Manages all shops",
"Office staff",
"Administrator"
};

and some standard functions in my selection model:
public int getOptionCount() {
return textOptions.length;
}

public Object getOption(int index) {
return new Integer(index);
}

public String getLabel(int index) {
return textOptions[index];
}

public String getValue(int index) {
return String.valueOf(index);
}

public Object translateValue(String value){
return Integer.parseInt(value);
}


and very normal stuff in my .page file:







All of this I had done before and everywhere else it was working fine.  But
suddenly this one didn't work.  Then it occured to me, maybe the value from
user.security wasn't being passed correctly.

public void setSecurity(short security) {
this.security = security;
}
public short getSecurity() {
return security;
}


It's a short!  Okay, so how does that affect setting the initial value for 
my

select.  I read through the documentation over and again, search the lists,
absolutely nothing.  It shouldn't affect it.  My other examples were of 
type
'int' and my guess is that Tapestry would cope with translating a short to 
an
int - not a chance.  I tried adapting the translateValue() function to 
return
Short.parseShort(value) but this still didn't work.  What else am I 
supposed to

change???

It appears that IPropertySelectionModel only works with integer values!  I
finally made a work around that looks like this:


and
public int getSecurityint() {
return (int) security;
}
public void setSecurityint(int sec) {
this.security = (short) sec;
}

How sad is that!

Okay, what should I have done?

Cheers
Murray



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



_
Advertisement: Fresh jobs daily. Stop waiting for the newspaper. Search Now! 
www.seek.com.au 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=757263760&_r=Hotmail_EndText_Dec06&_m=EXT



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



IPropertySelectionModel - what they don't write in the documentation

2007-02-12 Thread Murray Collingwood
Hello tapestry experts

The API documentation for IPropertySelectionModel is lacking key information. 
In particular how the initial value is defined.

What it should say is stuff like:

"To set the initial value of the HTML select element you need to bind a value to
this control.  The type of value bound is important  [This is where somebody
else needs to take over.]"

I have spent all day trying to initialise a value in my HTML select element.  I
had searched through the lists and the web but I didn't find anything like what
I was experiencing.  Check out this:

I had a static list of security levels:
private static final String[] textOptions = new String[]{
"(none)",
"Quoting",
"Ordering",
"Shop manager",
"Manages all shops",
"Office staff",
"Administrator"
};

and some standard functions in my selection model:
public int getOptionCount() {
return textOptions.length;
}

public Object getOption(int index) {
return new Integer(index);
}

public String getLabel(int index) {
return textOptions[index];
}

public String getValue(int index) {
return String.valueOf(index);
}

public Object translateValue(String value){
return Integer.parseInt(value);
}   


and very normal stuff in my .page file:







All of this I had done before and everywhere else it was working fine.  But
suddenly this one didn't work.  Then it occured to me, maybe the value from
user.security wasn't being passed correctly.

public void setSecurity(short security) {
this.security = security;
}
public short getSecurity() {
return security;
}


It's a short!  Okay, so how does that affect setting the initial value for my
select.  I read through the documentation over and again, search the lists,
absolutely nothing.  It shouldn't affect it.  My other examples were of type
'int' and my guess is that Tapestry would cope with translating a short to an
int - not a chance.  I tried adapting the translateValue() function to return
Short.parseShort(value) but this still didn't work.  What else am I supposed to
change???

It appears that IPropertySelectionModel only works with integer values!  I
finally made a work around that looks like this:


and
public int getSecurityint() {
return (int) security;
}
public void setSecurityint(int sec) {
this.security = (short) sec;
}

How sad is that!

Okay, what should I have done?

Cheers
Murray



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