tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dr Paul Gorman <drpau...@gmail.com>
Subject Re: Using Visit object to store wml:PropertySelection values
Date Tue, 13 Sep 2005 03:37:18 GMT
Hi Benu,

I've had a look at this and the issue is with the property selection not 
working as advertised. I looked at the source code to see if it is doing 
what it says and it is not.

According to the docs:

http://jakarta.apache.org/tapestry/3.0.3/doc/ComponentReference/wml.PropertySelection.html

For the name parameter:

"The property to set. During rendering, this property is read, and sets the 
default value of the selection (if it is null, no element is selected). When 
the <go> is submitted, this property is updated, with the help of 
SelectionField component, based on the new selection."


The WML PropertySelection does the following:

for (int i = 0; i < count; i++)
{

writer.begin("option");
writer.attribute("value", model.getValue(i));

writer.print(model.getLabel(i));

writer.end();
writer.println();
}

Compared to the normal form one:

for (int i = 0; i < count; i++)
{
Object option = model.getOption(i);

if (!foundSelected)
{
selected = isEqual(option, value);
if (selected)
foundSelected = true;
}

writer.begin("option");
writer.attribute("value", model.getValue(i));

if (selected)
writer.attribute("selected", "selected");

writer.print(model.getLabel(i));

writer.end();

writer.println();

selected = false;
}


Cheers

Paul.


On 9/9/05, Benu Gupta <benu.gupta@aia.co.nz> wrote:
> 
> Hi,
> 
> I am using PropertySelection & SelectionField of wml library to display
> dropdowns in my wap pages.
> The fields are bound to variables defined in Visit object. On navigating 
> to
> next screen and then doing prev, the drop down values are not retained on
> screen. Text box values are fine.
> SelectionField has been used to post the values to server.
> 
> Code in .page file:
> 
> <property-specification name="agreedValue" type="java.lang.String"
> persistent="yes" initial-value='"Yes"'/>
> 
> <component id="agreedValueSelect" type="wml:PropertySelection">
> <static-binding name="name">agreedValue</static-binding>
> <binding name="model"
> expression="@com.olasme.wapclient.IPDetails@AGREED_VALUE_MODEL"/>
> </component>
> <component id="agreedValue" type="wml:SelectionField">
> <binding name="value"
> expression="visit.details.iPDetails.agreedValue"/>
> <binding name="model" expression="components.agreedValueSelect.model"/>
> <binding name="name"
> expression="components.agreedValueSelect.name<http://components.agreedValueSelect.name>
> "/>
> </component>
> <component id="cover" type="wml:Postfield">
> <binding name="name" expression="components.coverInput.name<http://components.coverInput.name>
> "/>
> <binding name="value"
> expression="visit.details.iPDetails.coverAmount"/>
> </component>
> 
> Code in .wml file
> 
> <b>Cover:</b> $$<input jwcid="coverInput@wml:Input" name="cover"
> value="ognl:visit.details.iPDetails.coverAmount" format="*N"
> emptyok="false"/><br/>
> <b>Agreed Value:</b> <span jwcid="agreedValueSelect"/><br/>
> <anchor>Prev
> <span jwcid="goPrev">
> <postfield jwcid="cover"/>
> <postfield jwcid="agreedValue"/>
> 
> </span>
> </anchor>
> <anchor>Next
> <span jwcid="goNext">
> <postfield jwcid="cover1"/>
> <postfield jwcid="agreedValue1"/>
> </span>
> </anchor>
> 
> 
> Code in .java file
> 
> public abstract String getAgreedValue();
> 
> 
> 
> 
> The drop down values are being posted to the server for processing, but 
> when i
> try to navigate back to the same screen to modify the values, the drop 
> down is
> reset and does not retain the one selected before.
> Any help in this matter will be greatly appreciated.
> 
> Thanks
> Benu Gupta
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message