You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Benu Gupta <be...@aia.co.nz> on 2005/09/09 06:38:58 UTC

Using Visit object to store wml:PropertySelection values

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"/>
  </component>
<component id="cover" type="wml:Postfield">
		<binding name="name" expression="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


Re: Using Visit object to store wml:PropertySelection values

Posted by Dr Paul Gorman <dr...@gmail.com>.
Replying to my own post... Not cool :-)

Heh. *blush* I just looked at the WML option tag (
http://www.w3schools.com/wap/tag_option.asp) and there is no 'selected' 
attribute so hence it is not available in the Tapestry WML component.

Looks like ivalue is used to select the option in the WML select (
http://www.w3schools.com/wap/tag_select.asp). Try an informal parameter in 
the select component to set the ivalue.

Paul


On 9/13/05, Dr Paul Gorman <dr...@gmail.com> wrote:
> 
> 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 <be...@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
> > 
> > 
>

Re: Using Visit object to store wml:PropertySelection values

Posted by Dr Paul Gorman <dr...@gmail.com>.
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 <be...@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
> 
>