You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mohammad Irfan <ir...@gmail.com> on 2008/08/27 11:54:23 UTC

T4.1 Property Selection component

Hi,

I have success in using Property selection component but I found a
problem. I'd like to ask, how can I set a selected value for the
Selection list?
So I can have this html output:

<select name="reportTypeSelection" id="reportTypeSelection">
<option value="0">CSV</option>
<option value="1">DBF</option>
<option value="2" selected>DELIM</option>
<option value="3">TXT</option>
<option value="4">XLS</option>

</select>

Thanks.
-- 
Mohammad Irfan

---
www.doktermaya.com
www.L-Ads.com (classifieds ads, iklan baris)
www.komplain.org (complain about product)
www.akarprima.com

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


Re: T4.1 Property Selection component

Posted by Mohammad Irfan <ir...@gmail.com>.
On my POJO model, the equals method is like this:

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		// if (!super.equals(obj))
		// return false;
		if (getClass() != obj.getClass())
			return false;
		ReportType other = (ReportType) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (reportTemplates == null) {
			if (other.reportTemplates != null)
				return false;
		} else if (!reportTemplates.equals(other.reportTemplates))
			return false;
		return true;
	}

It is generated from eclipse. And for the PropertySelectionModel the
code is like this:

public class ReportTypeSelectionModel implements IPropertySelectionModel,
		Serializable {
	private static final long serialVersionUID = 1823541941745724736L;
	private List<ReportType> rtList;
	public ReportTypeSelectionModel(List<ReportType> reptypList) {
		this.rtList = reptypList;
	}
	public String getLabel(int index) {
		return rtList.get(index).getCode();
	}
	public Object getOption(int index) {
		return rtList.get(index);
	}
	public int getOptionCount() {
		return rtList.size();
	}
	public String getValue(int index) {
		return Integer.toString(index);
	}
	public boolean isDisabled(int index) {
		// TODO Auto-generated method stub
		return false;
	}
	public Object translateValue(String value) {
		return getOption(Integer.parseInt(value));
	}
}


Do the PropertySelectionModel will select the value which it set using
setMyValue(theValue) on the page class?
On Fri, Aug 29, 2008 at 11:32 AM, Andreas Andreou <an...@gmail.com> wrote:
> is equals() implemented accordingly for your domain object?
>
> On Fri, Aug 29, 2008 at 7:09 AM, Mohammad Irfan <ir...@gmail.com> wrote:
>> Hi, getting the selected object from the list is not a problem. The
>> problem is if I want to edit an object where it has a property
>> selection on it's form, I want to set it according to the object's
>> value.
>>
>> The code:
>> <select jwcid="@PropertySelection" value="ognl:myValue" model="ognl:myValues" />
>>
>> I have a setter and geter for both model and value object:
>>
>> public abstract Value getMyValue();
>> public abstract void setMyValue(Value val);
>>
>> public abstract IPropertySelectionModel getMyValues(){
>> ...
>> }
>>
>> and on the page begin render, I have set the default value if I'm
>> editting the object:
>>
>> public void pageBeginRender(PageEvent event) {
>> .....
>>   setMyValue( getObject().getValue() );
>> }
>>
>> But, nothing is happened. The list is always selecting the first
>> value, not the object's value that I want.
>>
>> Thanks.
>>
>> On Wed, Aug 27, 2008 at 10:06 PM, Norman Franke <no...@myasd.com> wrote:
>>> This is handled automatically based on the "value" parameter for the
>>> tapestry object.
>>>
>>> <select jwcid="@PropertySelection" value="ognl:myValue"
>>> model="ognl:myValues" />
>>>
>>> You can use an existing model, or implement IPropertySelectionModel which
>>> Tapestry uses to translate values and the like.
>>>
>>> Norman Franke
>>> Answering Service for Directors, Inc.
>>> www.myasd.com
>>>
>>> On Aug 27, 2008, at 5:54 AM, Mohammad Irfan wrote:
>>>
>>>> Hi,
>>>>
>>>> I have success in using Property selection component but I found a
>>>> problem. I'd like to ask, how can I set a selected value for the
>>>> Selection list?
>>>> So I can have this html output:
>>>>
>>>> <select name="reportTypeSelection" id="reportTypeSelection">
>>>> <option value="0">CSV</option>
>>>> <option value="1">DBF</option>
>>>> <option value="2" selected>DELIM</option>
>>>> <option value="3">TXT</option>
>>>> <option value="4">XLS</option>
>>>>
>>>> </select>
>>>>
>>>> Thanks.
>>>> --
>>>> Mohammad Irfan
>>>>
>>>> ---
>>>> www.doktermaya.com
>>>> www.L-Ads.com (classifieds ads, iklan baris)
>>>> www.komplain.org (complain about product)
>>>> www.akarprima.com
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Wassalamu'alaikum wr. wb.
>> Mohammad Irfan
>>
>> ---
>> www.doktermaya.com
>> www.L-Ads.com (classifieds ads, iklan baris)
>> www.komplain.org (complain about product)
>> www.akarprima.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Wassalamu'alaikum wr. wb.
Mohammad Irfan

---
www.doktermaya.com
www.L-Ads.com (classifieds ads, iklan baris)
www.komplain.org (complain about product)
www.akarprima.com

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


Re: T4.1 Property Selection component

Posted by Andreas Andreou <an...@gmail.com>.
is equals() implemented accordingly for your domain object?

On Fri, Aug 29, 2008 at 7:09 AM, Mohammad Irfan <ir...@gmail.com> wrote:
> Hi, getting the selected object from the list is not a problem. The
> problem is if I want to edit an object where it has a property
> selection on it's form, I want to set it according to the object's
> value.
>
> The code:
> <select jwcid="@PropertySelection" value="ognl:myValue" model="ognl:myValues" />
>
> I have a setter and geter for both model and value object:
>
> public abstract Value getMyValue();
> public abstract void setMyValue(Value val);
>
> public abstract IPropertySelectionModel getMyValues(){
> ...
> }
>
> and on the page begin render, I have set the default value if I'm
> editting the object:
>
> public void pageBeginRender(PageEvent event) {
> .....
>   setMyValue( getObject().getValue() );
> }
>
> But, nothing is happened. The list is always selecting the first
> value, not the object's value that I want.
>
> Thanks.
>
> On Wed, Aug 27, 2008 at 10:06 PM, Norman Franke <no...@myasd.com> wrote:
>> This is handled automatically based on the "value" parameter for the
>> tapestry object.
>>
>> <select jwcid="@PropertySelection" value="ognl:myValue"
>> model="ognl:myValues" />
>>
>> You can use an existing model, or implement IPropertySelectionModel which
>> Tapestry uses to translate values and the like.
>>
>> Norman Franke
>> Answering Service for Directors, Inc.
>> www.myasd.com
>>
>> On Aug 27, 2008, at 5:54 AM, Mohammad Irfan wrote:
>>
>>> Hi,
>>>
>>> I have success in using Property selection component but I found a
>>> problem. I'd like to ask, how can I set a selected value for the
>>> Selection list?
>>> So I can have this html output:
>>>
>>> <select name="reportTypeSelection" id="reportTypeSelection">
>>> <option value="0">CSV</option>
>>> <option value="1">DBF</option>
>>> <option value="2" selected>DELIM</option>
>>> <option value="3">TXT</option>
>>> <option value="4">XLS</option>
>>>
>>> </select>
>>>
>>> Thanks.
>>> --
>>> Mohammad Irfan
>>>
>>> ---
>>> www.doktermaya.com
>>> www.L-Ads.com (classifieds ads, iklan baris)
>>> www.komplain.org (complain about product)
>>> www.akarprima.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> Wassalamu'alaikum wr. wb.
> Mohammad Irfan
>
> ---
> www.doktermaya.com
> www.L-Ads.com (classifieds ads, iklan baris)
> www.komplain.org (complain about product)
> www.akarprima.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: T4.1 Property Selection component

Posted by Mohammad Irfan <ir...@gmail.com>.
Hi, getting the selected object from the list is not a problem. The
problem is if I want to edit an object where it has a property
selection on it's form, I want to set it according to the object's
value.

The code:
<select jwcid="@PropertySelection" value="ognl:myValue" model="ognl:myValues" />

I have a setter and geter for both model and value object:

public abstract Value getMyValue();
public abstract void setMyValue(Value val);

public abstract IPropertySelectionModel getMyValues(){
...
}

and on the page begin render, I have set the default value if I'm
editting the object:

public void pageBeginRender(PageEvent event) {
.....
   setMyValue( getObject().getValue() );
}

But, nothing is happened. The list is always selecting the first
value, not the object's value that I want.

Thanks.

On Wed, Aug 27, 2008 at 10:06 PM, Norman Franke <no...@myasd.com> wrote:
> This is handled automatically based on the "value" parameter for the
> tapestry object.
>
> <select jwcid="@PropertySelection" value="ognl:myValue"
> model="ognl:myValues" />
>
> You can use an existing model, or implement IPropertySelectionModel which
> Tapestry uses to translate values and the like.
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
> On Aug 27, 2008, at 5:54 AM, Mohammad Irfan wrote:
>
>> Hi,
>>
>> I have success in using Property selection component but I found a
>> problem. I'd like to ask, how can I set a selected value for the
>> Selection list?
>> So I can have this html output:
>>
>> <select name="reportTypeSelection" id="reportTypeSelection">
>> <option value="0">CSV</option>
>> <option value="1">DBF</option>
>> <option value="2" selected>DELIM</option>
>> <option value="3">TXT</option>
>> <option value="4">XLS</option>
>>
>> </select>
>>
>> Thanks.
>> --
>> Mohammad Irfan
>>
>> ---
>> www.doktermaya.com
>> www.L-Ads.com (classifieds ads, iklan baris)
>> www.komplain.org (complain about product)
>> www.akarprima.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Wassalamu'alaikum wr. wb.
Mohammad Irfan

---
www.doktermaya.com
www.L-Ads.com (classifieds ads, iklan baris)
www.komplain.org (complain about product)
www.akarprima.com

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


Re: T4.1 Property Selection component

Posted by Norman Franke <no...@myasd.com>.
This is handled automatically based on the "value" parameter for the  
tapestry object.

<select jwcid="@PropertySelection" value="ognl:myValue"  
model="ognl:myValues" />

You can use an existing model, or implement IPropertySelectionModel  
which Tapestry uses to translate values and the like.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com

On Aug 27, 2008, at 5:54 AM, Mohammad Irfan wrote:

> Hi,
>
> I have success in using Property selection component but I found a
> problem. I'd like to ask, how can I set a selected value for the
> Selection list?
> So I can have this html output:
>
> <select name="reportTypeSelection" id="reportTypeSelection">
> <option value="0">CSV</option>
> <option value="1">DBF</option>
> <option value="2" selected>DELIM</option>
> <option value="3">TXT</option>
> <option value="4">XLS</option>
>
> </select>
>
> Thanks.
> -- 
> Mohammad Irfan
>
> ---
> www.doktermaya.com
> www.L-Ads.com (classifieds ads, iklan baris)
> www.komplain.org (complain about product)
> www.akarprima.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



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