You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Lewis <ch...@bellsouth.net> on 2007/08/16 00:54:23 UTC

T5: radio, label

Hello,

I'm trying to get a simple form with some radio buttons and labels 
working, without success. Following is the source for my Login page 
template and class. Note that the page is rendering in a layout component.

Login.html:
<div t:type="layouts/General" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <t:Form>
        <t:RadioGroup value="listerType" encoder="stringEncoder">
            <t:Label for="reg-agent">Type</t:Label>
            <t:Radio id="reg-agent" type="radio" value="listerType"/>
            <t:Radio id="reg-fsbo" type="radio" value="listerType"/>
           
        </t:RadioGroup>
    </t:Form>
</div>

Login.java
public class Login {
   
    public static final String AGENT_LISTER="AGENT";
    public static final String AGENT_FSBO="FSBO";
    private String listerType = AGENT_LISTER;
    private StringValueEncoder stringEncoder = new StringValueEncoder();

    /**
     * @return the listerType
     */
    public String getListerType() {
        return listerType;
    }

    /**
     * @param listerType the listerType to set
     */
    public void setListerType(String listerType) {
        this.listerType = listerType;
    }

    /**
     * @return the stringEncoder
     */
    public StringValueEncoder getStringEncoder() {
        return stringEncoder;
    }
}

When I visit the page I am greeted with a "Failure reading parameter for 
of component listers/Login:label: Component listers/Login does not 
contain an embedded component with id 'reg-agent'." exception, but there 
is a component with id reg-agent!

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


Re: T5: radiogroup, label BUG?

Posted by Chris Lewis <ch...@bellsouth.net>.
While I am enjoying a conversation with myself, input from anyone using 
T5 and radio buttons (surely someone else) would be awesome. So I poked 
around a bit more in the RadioGroup source and see that, for some reason 
that evades me, RadioGroup creates an anonyous/ad-hoc implementation of 
RadioContainer on the fly, and shoves it into the environment. So, it 
*should* work, and in fact it does if I don't use any label components 
within the form. However the moment I add a <t:label/> I get the 
exception about no RadioContainer! Using a raw <label></label> works 
fine, but what in the world is going on here? I can only guess this is a 
bug, but input would much appreciated.

Another annoyance is the component reference. The RadioGroup lists the 
encoder parameter as required (and its marked as required in the 
source), but if I don't provide it it works anyway, so apparently a 
default implementation is being added somewhere. This would be fine, but 
as the developer I should be made aware of this. Are things like this 
undocumented because its all still in development?

sincerely,
chris

Chris Lewis wrote:
> Ok so I learned that the id parameter must be in the t: namespace, so 
> changing the radio component to have 't:id="reg-agent"'. Now I'm 
> greeted with a new exception:
>
> "No object of type org.apache.tapestry.RadioContainer is available 
> from the Environment."
>
> And then it lists several objects in teh environment. What's annoying 
> is that the component ref says that the RadioGroup (or some impl of 
> RadioContainer) must contain radio components, so my code should work. 
> However I looked at the source for RadioGroup, and doesn't implement 
> the RadioContainer interface!! Is this a bug?
>
> Chris Lewis wrote:
>> Hello,
>>
>> I'm trying to get a simple form with some radio buttons and labels 
>> working, without success. Following is the source for my Login page 
>> template and class. Note that the page is rendering in a layout 
>> component.
>>
>> Login.html:
>> <div t:type="layouts/General" 
>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>>    <t:Form>
>>        <t:RadioGroup value="listerType" encoder="stringEncoder">
>>            <t:Label for="reg-agent">Type</t:Label>
>>            <t:Radio id="reg-agent" type="radio" value="listerType"/>
>>            <t:Radio id="reg-fsbo" type="radio" value="listerType"/>
>>                  </t:RadioGroup>
>>    </t:Form>
>> </div>
>>
>> Login.java
>> public class Login {
>>      public static final String AGENT_LISTER="AGENT";
>>    public static final String AGENT_FSBO="FSBO";
>>    private String listerType = AGENT_LISTER;
>>    private StringValueEncoder stringEncoder = new StringValueEncoder();
>>
>>    /**
>>     * @return the listerType
>>     */
>>    public String getListerType() {
>>        return listerType;
>>    }
>>
>>    /**
>>     * @param listerType the listerType to set
>>     */
>>    public void setListerType(String listerType) {
>>        this.listerType = listerType;
>>    }
>>
>>    /**
>>     * @return the stringEncoder
>>     */
>>    public StringValueEncoder getStringEncoder() {
>>        return stringEncoder;
>>    }
>> }
>>
>> When I visit the page I am greeted with a "Failure reading parameter 
>> for of component listers/Login:label: Component listers/Login does 
>> not contain an embedded component with id 'reg-agent'." exception, 
>> but there is a component with id reg-agent!
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: T5: radio, label

Posted by Chris Lewis <ch...@bellsouth.net>.
tamseo,

I didn't see RadioDemo, so thanks for pointing that out! Have you run it 
and does it work? The only difference from my example I can see is that 
the radio and label components are rendered in a child loop of the 
containing radio group, but that shouldn't make a difference.

tamseo wrote:
> Chris !
>
> I followed RadioDemo test in T5 source, and i'm in the same situation with
> you.
> Now I'using  HTML <label> and waiting for answer from T5 experienced user.
>
>
>
>   


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


Re: T5: radio, label

Posted by tamseo <ta...@key-planning.co.jp>.
Chris !

I followed RadioDemo test in T5 source, and i'm in the same situation with
you.
Now I'using  HTML <label> and waiting for answer from T5 experienced user.



-- 
View this message in context: http://www.nabble.com/T5%3A-radio%2C-label-tf4276314.html#a12174593
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: radio, label

Posted by "Nick Westgate (Work)" <ni...@key-planning.co.jp>.
You're welcome.
It wasn't a known issue before you found it. I just debugged and logged it.

The benefits of using the label component are:
- DRY: a component declares its label once, and the Label refers to it
- validation decoration of the resulting label

Cheers,
Nick.



Chris Lewis-5 wrote:
> 
> Nick, thanks for pointing that out and I'm glad to see its a known issue 
> (hopefully that means a fix is coming). Thanks for your solution, but 
> I'd rather just use the raw label tag. I'm not entirely sure what the 
> benefit of using the the label component is to be honest, but it was one 
> of those thing where I felt like I had to understand what was happening 
> (I'm new to tap).
> Thanks again!
> 
> chris
> 
> Nick Westgate wrote:
>> The problem is actually in the Radio component.
>> Copy its source to make your own component and apply these changes:
>> https://issues.apache.org/jira/browse/TAPESTRY-1709
>>
>> Cheers,
>> Nick.
>>
>>
>> Chris Lewis wrote:
>>> tamseo,
>>>
>>> Let me amend my last message. I can use <t:label> in the form as long 
>>> as its not a child of the <t:radiogroup> component!
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-radio%2C-label-tf4276314.html#a12183202
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: radio, label

Posted by Chris Lewis <ch...@bellsouth.net>.
Nick, thanks for pointing that out and I'm glad to see its a known issue 
(hopefully that means a fix is coming). Thanks for your solution, but 
I'd rather just use the raw label tag. I'm not entirely sure what the 
benefit of using the the label component is to be honest, but it was one 
of those thing where I felt like I had to understand what was happening 
(I'm new to tap).
Thanks again!

chris

Nick Westgate wrote:
> The problem is actually in the Radio component.
> Copy its source to make your own component and apply these changes:
> https://issues.apache.org/jira/browse/TAPESTRY-1709
>
> Cheers,
> Nick.
>
>
> Chris Lewis wrote:
>> tamseo,
>>
>> Let me amend my last message. I can use <t:label> in the form as long 
>> as its not a child of the <t:radiogroup> component!
>
>
> ---------------------------------------------------------------------
> 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


Re: T5: radio, label

Posted by Nick Westgate <ni...@key-planning.co.jp>.
The problem is actually in the Radio component.
Copy its source to make your own component and apply these changes:
https://issues.apache.org/jira/browse/TAPESTRY-1709

Cheers,
Nick.


Chris Lewis wrote:
> tamseo,
> 
> Let me amend my last message. I can use <t:label> in the form as long as 
> its not a child of the <t:radiogroup> component!


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


Re: T5: radio, label

Posted by Chris Lewis <ch...@bellsouth.net>.
tamseo,

Let me amend my last message. I can use <t:label> in the form as long as 
its not a child of the <t:radiogroup> component!
It's also important to note that my label components fail to find the 
component indicated in the for attribute, unless that component declares 
its id in the t: namespace. So, <t:radio id="reg-agent"/> will not work, 
but <t:radio t:id="reg-agent"/> will.
> I think if you remove the label component your code will work.
>   
Yeah, removing the label component works, but I should be able to use it 
shouldn't I?
> or add "label" attribute for Radio like this
>
> <t:Label for="reg-agent"/>
> <t:Radio id="reg-agent" type="radio" value="listerType" label="xxx" />
>
>   
I tried this and it still doesn't work!
> in my opinion we can't use Label like this <t:Label
> for="reg-agent">Type</t:Label>
>
>   
You're right here - the label component does not render its body.

Here is what my template looks like now:

    <t:form t:id="register">
        <t:radiogroup t:value="listerType" t:encoder="stringEncoder">
            <t:label for="reg-agent"/> <!-- label with in RadioGroup 
causes error! -->
            <t:radio t:id="reg-agent" value="listerType" label="the label"/>
            <t:radio t:id="reg-fsbo" value="listerType"/>
        </t:radiogroup>
        <t:textfield t:id="text" value="literal:can't submit literals"/>
        <t:submit value="Login"/>
    </t:form>
>
> Chris Lewis wrote:
>   
>> Hello,
>>
>> I'm trying to get a simple form with some radio buttons and labels 
>> working, without success. Following is the source for my Login page 
>> template and class. Note that the page is rendering in a layout 
>> component.
>>
>> Login.html:
>> <div t:type="layouts/General" 
>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>>    <t:Form>
>>        <t:RadioGroup value="listerType" encoder="stringEncoder">
>>            <t:Label for="reg-agent">Type</t:Label>
>>            <t:Radio id="reg-agent" type="radio" value="listerType"/>
>>            <t:Radio id="reg-fsbo" type="radio" value="listerType"/>
>>                  </t:RadioGroup>
>>    </t:Form>
>> </div>
>>
>> Login.java
>> public class Login {
>>      public static final String AGENT_LISTER="AGENT";
>>    public static final String AGENT_FSBO="FSBO";
>>    private String listerType = AGENT_LISTER;
>>    private StringValueEncoder stringEncoder = new StringValueEncoder();
>>
>>    /**
>>     * @return the listerType
>>     */
>>    public String getListerType() {
>>        return listerType;
>>    }
>>
>>    /**
>>     * @param listerType the listerType to set
>>     */
>>    public void setListerType(String listerType) {
>>        this.listerType = listerType;
>>    }
>>
>>    /**
>>     * @return the stringEncoder
>>     */
>>    public StringValueEncoder getStringEncoder() {
>>        return stringEncoder;
>>    }
>> }
>>
>> When I visit the page I am greeted with a "Failure reading parameter 
>> for of component listers/Login:label: Component listers/Login does not 
>> contain an embedded component with id 'reg-agent'." exception, but 
>> there is a component with id reg-agent!
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
>
>   


Re: T5: radio, label

Posted by tamseo <ta...@key-planning.co.jp>.
Hi Chris!

I think if you remove the label component your code will work.

or add "label" attribute for Radio like this

<t:Label for="reg-agent"/>
<t:Radio id="reg-agent" type="radio" value="listerType" label="xxx" />

in my opinion we can't use Label like this <t:Label
for="reg-agent">Type</t:Label>



Chris Lewis wrote:
> Hello,
>
> I'm trying to get a simple form with some radio buttons and labels 
> working, without success. Following is the source for my Login page 
> template and class. Note that the page is rendering in a layout 
> component.
>
> Login.html:
> <div t:type="layouts/General" 
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>    <t:Form>
>        <t:RadioGroup value="listerType" encoder="stringEncoder">
>            <t:Label for="reg-agent">Type</t:Label>
>            <t:Radio id="reg-agent" type="radio" value="listerType"/>
>            <t:Radio id="reg-fsbo" type="radio" value="listerType"/>
>                  </t:RadioGroup>
>    </t:Form>
> </div>
>
> Login.java
> public class Login {
>      public static final String AGENT_LISTER="AGENT";
>    public static final String AGENT_FSBO="FSBO";
>    private String listerType = AGENT_LISTER;
>    private StringValueEncoder stringEncoder = new StringValueEncoder();
>
>    /**
>     * @return the listerType
>     */
>    public String getListerType() {
>        return listerType;
>    }
>
>    /**
>     * @param listerType the listerType to set
>     */
>    public void setListerType(String listerType) {
>        this.listerType = listerType;
>    }
>
>    /**
>     * @return the stringEncoder
>     */
>    public StringValueEncoder getStringEncoder() {
>        return stringEncoder;
>    }
> }
>
> When I visit the page I am greeted with a "Failure reading parameter 
> for of component listers/Login:label: Component listers/Login does not 
> contain an embedded component with id 'reg-agent'." exception, but 
> there is a component with id reg-agent!
>
> ---------------------------------------------------------------------
> 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




-- 
View this message in context: http://www.nabble.com/T5%3A-radio%2C-label-tf4276314.html#a12174382
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: radio, label

Posted by Chris Lewis <ch...@bellsouth.net>.
Ok so I learned that the id parameter must be in the t: namespace, so 
changing the radio component to have 't:id="reg-agent"'. Now I'm greeted 
with a new exception:

"No object of type org.apache.tapestry.RadioContainer is available from 
the Environment."

And then it lists several objects in teh environment. What's annoying is 
that the component ref says that the RadioGroup (or some impl of 
RadioContainer) must contain radio components, so my code should work. 
However I looked at the source for RadioGroup, and doesn't implement the 
RadioContainer interface!! Is this a bug?

Chris Lewis wrote:
> Hello,
>
> I'm trying to get a simple form with some radio buttons and labels 
> working, without success. Following is the source for my Login page 
> template and class. Note that the page is rendering in a layout 
> component.
>
> Login.html:
> <div t:type="layouts/General" 
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>    <t:Form>
>        <t:RadioGroup value="listerType" encoder="stringEncoder">
>            <t:Label for="reg-agent">Type</t:Label>
>            <t:Radio id="reg-agent" type="radio" value="listerType"/>
>            <t:Radio id="reg-fsbo" type="radio" value="listerType"/>
>                  </t:RadioGroup>
>    </t:Form>
> </div>
>
> Login.java
> public class Login {
>      public static final String AGENT_LISTER="AGENT";
>    public static final String AGENT_FSBO="FSBO";
>    private String listerType = AGENT_LISTER;
>    private StringValueEncoder stringEncoder = new StringValueEncoder();
>
>    /**
>     * @return the listerType
>     */
>    public String getListerType() {
>        return listerType;
>    }
>
>    /**
>     * @param listerType the listerType to set
>     */
>    public void setListerType(String listerType) {
>        this.listerType = listerType;
>    }
>
>    /**
>     * @return the stringEncoder
>     */
>    public StringValueEncoder getStringEncoder() {
>        return stringEncoder;
>    }
> }
>
> When I visit the page I am greeted with a "Failure reading parameter 
> for of component listers/Login:label: Component listers/Login does not 
> contain an embedded component with id 'reg-agent'." exception, but 
> there is a component with id reg-agent!
>
> ---------------------------------------------------------------------
> 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


Re: T5: radio, label

Posted by tamseo <ta...@key-planning.co.jp>.
This is my simple example, I craeted it just to check how to use Radio 

html:

<div t:type="form">
		<div t:type="radiogroup" t:id="nameoption">
		 	  <div t:type="radio" t:id="radio1" t:value="name1"
/><label>${name1}</label>
			  <br/>
			 <div t:type="radio" t:id="radio2"
t:value="name2"/><label>${name2}</label>
	    </div> 
		<p>
      <input type="submit" value="Select"/>
      </p>
	</div>
	
  <div t:type="if" t:test="nameoption">
      ${nameoption} has been selected
  </div>


Page class

        @Persist
	private String nameoption;
	private String name1 = "Option1";
	private String name2 = "Option2";

 i ignore setter and getter here.
-- 
View this message in context: http://www.nabble.com/T5%3A-radio%2C-label-tf4276314.html#a12174779
Sent from the Tapestry - User mailing list archive at Nabble.com.


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