Re: [T5] RadioGroup and Radio holding enum values
This should be possible by going over an EnumSet (or anything else Iterable) with the loop component and rendering an option component in every iteration. Something like @Property private EnumSet enums; @Property private EnumType enum; @Property private EnumType loopValue; I just wrote that down from memory, no guarantee that this works but you might try it. HTH, Uli Alexey Hanin schrieb: But what if I'll have to deal with variable length radio groups where item value can't be hard-coded? On Wed, Oct 8, 2008 at 4:43 PM, Ulrich Stärk <[EMAIL PROTECTED]> wrote: I believe you'll have to write a TypeCoercer from String to EnumType and back and contribute that to the TypeCoercer service. See http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/TapestryModule.html for examples how to do this. But if you can live with your values not being literal strings, you could just follow the example here: http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Radio.html HTH, Uli Am Mi, 8.10.2008, 15:10, schrieb Alexey Hanin: Hello, I'm trying to use RadioGroup with Enum values and getting ClassCastException: java.lang.String cannot be cast to java.lang.Enum. My page is as follows: public class Page { private EnumValueEncoder enumTypeEncoder = new EnumValueEncoder(EnumType.class); private EnumType enumType; public EnumType getEnumType() { return enumType; } public void setEnumType(EnumType enumType) { this.enumType = enumType; } public EnumValueEncoder getEnumTypeEncoder() { return enumTypeEncoder; } } public enum EnumType { A, B } I supposed literal representation must be evaluated to corresponding enum values and wise-versa, but I got a ClassCastException. I found this way logical and I really don't want to use getters for every element of enum. Is there any ways to achieve this? Tapestry version is 5.0.15 Regards, Alexey. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup and Radio holding enum values
But what if I'll have to deal with variable length radio groups where item value can't be hard-coded? On Wed, Oct 8, 2008 at 4:43 PM, Ulrich Stärk <[EMAIL PROTECTED]> wrote: > I believe you'll have to write a TypeCoercer from String to EnumType and > back and contribute that to the TypeCoercer service. See > http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/TapestryModule.html > for examples how to do this. > > But if you can live with your values not being literal strings, you could > just follow the example here: > http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Radio.html > > HTH, > > Uli > > Am Mi, 8.10.2008, 15:10, schrieb Alexey Hanin: >> Hello, >> >> I'm trying to use RadioGroup with Enum values and getting >> ClassCastException: java.lang.String cannot be cast to java.lang.Enum. >> >> My page is as follows: >> >> public class Page { >> >> private EnumValueEncoder enumTypeEncoder = new >> EnumValueEncoder(EnumType.class); >> private EnumType enumType; >> >> public EnumType getEnumType() { >> return enumType; >> } >> >> public void setEnumType(EnumType enumType) { >> this.enumType = enumType; >> } >> >> public EnumValueEncoder getEnumTypeEncoder() { >> return enumTypeEncoder; >> } >> } >> >> public enum EnumType { >> A, B >> } >> >> >> >> >> >> >> I supposed literal representation must be evaluated to corresponding >> enum values and wise-versa, but I got a ClassCastException. >> >> I found this way logical and I really don't want to use getters for >> every element of enum. Is there any ways to achieve this? >> >> Tapestry version is 5.0.15 >> >> Regards, >> Alexey. >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup and Radio holding enum values
I believe you'll have to write a TypeCoercer from String to EnumType and back and contribute that to the TypeCoercer service. See http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/TapestryModule.html for examples how to do this. But if you can live with your values not being literal strings, you could just follow the example here: http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Radio.html HTH, Uli Am Mi, 8.10.2008, 15:10, schrieb Alexey Hanin: > Hello, > > I'm trying to use RadioGroup with Enum values and getting > ClassCastException: java.lang.String cannot be cast to java.lang.Enum. > > My page is as follows: > > public class Page { > > private EnumValueEncoder enumTypeEncoder = new > EnumValueEncoder(EnumType.class); > private EnumType enumType; > > public EnumType getEnumType() { > return enumType; > } > > public void setEnumType(EnumType enumType) { > this.enumType = enumType; > } > > public EnumValueEncoder getEnumTypeEncoder() { > return enumTypeEncoder; > } > } > > public enum EnumType { > A, B > } > > > > > > > I supposed literal representation must be evaluated to corresponding > enum values and wise-versa, but I got a ClassCastException. > > I found this way logical and I really don't want to use getters for > every element of enum. Is there any ways to achieve this? > > Tapestry version is 5.0.15 > > Regards, > Alexey. > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5] RadioGroup and Radio holding enum values
Hello, I'm trying to use RadioGroup with Enum values and getting ClassCastException: java.lang.String cannot be cast to java.lang.Enum. My page is as follows: public class Page { private EnumValueEncoder enumTypeEncoder = new EnumValueEncoder(EnumType.class); private EnumType enumType; public EnumType getEnumType() { return enumType; } public void setEnumType(EnumType enumType) { this.enumType = enumType; } public EnumValueEncoder getEnumTypeEncoder() { return enumTypeEncoder; } } public enum EnumType { A, B } I supposed literal representation must be evaluated to corresponding enum values and wise-versa, but I got a ClassCastException. I found this way logical and I really don't want to use getters for every element of enum. Is there any ways to achieve this? Tapestry version is 5.0.15 Regards, Alexey. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: RadioGroup and null?
Hi Uli, I figured any Object-type, including a Boolean, could be set to null, but indeed when I change the type to a String it works. Thanks a lot. regards, Onno Scheffers On Wed, Oct 1, 2008 at 3:18 PM, Ulrich Stärk <[EMAIL PROTECTED]> wrote: > Boolean values cannot be set to null. If selection is a boolean variable > then it's always false except when it gets set to true. Use some other > type for your variable (e.g. String and parse that to boolean if it's not > null, use literal:true and literal:false in your radios). This will work. > > Uli > > Am Mi, 1.10.2008, 14:58, schrieb Onno Scheffers: > > I just upgraded to T5.0.15. Still the same problem. > > Anyone? > > > > > > On Tue, Sep 30, 2008 at 12:21 AM, Onno Scheffers <[EMAIL PROTECTED]> wrote: > > > >> I'm using T5.0.14 and I'd like to get back null from a RadioGroup if the > >> user didn't click on any radio-buttons, but it seems the RadioGroup > >> doesn't > >> support this? > >> > >> > >> > >> > >> > >> > >> This return false if no selection was made by the user. > >> > >> > >> regards, > >> > >> Onno Scheffers > >> > >> > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: T5: RadioGroup and null?
Boolean values cannot be set to null. If selection is a boolean variable then it's always false except when it gets set to true. Use some other type for your variable (e.g. String and parse that to boolean if it's not null, use literal:true and literal:false in your radios). This will work. Uli Am Mi, 1.10.2008, 14:58, schrieb Onno Scheffers: > I just upgraded to T5.0.15. Still the same problem. > Anyone? > > > On Tue, Sep 30, 2008 at 12:21 AM, Onno Scheffers <[EMAIL PROTECTED]> wrote: > >> I'm using T5.0.14 and I'd like to get back null from a RadioGroup if the >> user didn't click on any radio-buttons, but it seems the RadioGroup >> doesn't >> support this? >> >> >> >> >> >> >> This return false if no selection was made by the user. >> >> >> regards, >> >> Onno Scheffers >> >> > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: RadioGroup and null?
I just upgraded to T5.0.15. Still the same problem. Anyone? On Tue, Sep 30, 2008 at 12:21 AM, Onno Scheffers <[EMAIL PROTECTED]> wrote: > I'm using T5.0.14 and I'd like to get back null from a RadioGroup if the > user didn't click on any radio-buttons, but it seems the RadioGroup doesn't > support this? > > > > > > > This return false if no selection was made by the user. > > > regards, > > Onno Scheffers > >
T5: RadioGroup and null?
I'm using T5.0.14 and I'd like to get back null from a RadioGroup if the user didn't click on any radio-buttons, but it seems the RadioGroup doesn't support this? This return false if no selection was made by the user. regards, Onno Scheffers
Re: [T5] RadioGroup and varible numbers of radio buttons
@Christophe @Stephane Thanks to both of you. That did the trick. I have now two RadioButtons within the RadioGroup. One of them inside the loop and one outside owning different id's but same name. Now it is working as expected. again thanks for the quick response Jens No, Tapestry will give different ids to your radio tags inside the loop. In the HTML page, a radio belongs to a radiogroup if it has the same "name" parameter, not the same "id". And Tapestry will give a different id but the same "name" to each radio you put in a radiogroup wether it is in a loop or not. Stephane [EMAIL PROTECTED] a écrit : > Yes, but within the SAME radio group. > I mean: I use it multiple times within the loop? > > Jens > > > > > You use the id "radio" 2 times in the same tml page. That's not allowed. > > Stephane > > [EMAIL PROTECTED] a écrit : > >> Hi! >> >> I have a problem to handle a radiogroup having a variable number of radio >> > buttons created within a loop. > >> The 'tml' looks basically like the following code snippet: >> >> >> >> >> > > value="${loopAddress.userId}"/>${loopAddress.userId} > >> ${loopAddress.firstName} >> > ${loopAddress.lastName} > >> >> >> >> >> this works just fine. >> >> After adding a additional radio button outside the loop Tapestry complains >> > that the component with the id "radio" already exists? > >> >> >> >> > > value="${loopAddress.userId}"/>${loopAddress.userId} > >> ${loopAddress.firstName} >> > ${loopAddress.lastName} > >> >> >> >> >> >> What is the difference to the loop? >> So as a workaround I added an empty entry to the address list and preserved >> > the layout by using blocks but I really do not understand why this is > not working. > >> Any ideas? >> >> Thanks in advance >> >> Jens >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [T5] RadioGroup and varible numbers of radio buttons
Actually, I think there is only one instance of the radio component created inside the loop. And, it is used multiple times for each iteration to display radios, Tapestry generate clients ids at runtime. Component id must be unique to access it through the @Component annotation without any ambiguity. "t:id" is used for server component identification. Christophe. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : vendredi 14 mars 2008 10:48 À : users@tapestry.apache.org Objet : Re: [T5] RadioGroup and varible numbers of radio buttons Yes, but within the SAME radio group. I mean: I use it multiple times within the loop? Jens You use the id "radio" 2 times in the same tml page. That's not allowed. Stephane [EMAIL PROTECTED] a écrit : > Hi! > > I have a problem to handle a radiogroup having a variable number of radio buttons created within a loop. > The 'tml' looks basically like the following code snippet: > > > > > ${loopAddress.userId} > ${loopAddress.firstName} ${loopAddress.lastName} > > > > > this works just fine. > > After adding a additional radio button outside the loop Tapestry complains that the component with the id "radio" already exists? > > > > > ${loopAddress.userId} > ${loopAddress.firstName} ${loopAddress.lastName} > > > > > > What is the difference to the loop? > So as a workaround I added an empty entry to the address list and preserved the layout by using blocks but I really do not understand why this is not working. > > Any ideas? > > Thanks in advance > > Jens > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis. This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
Re: [T5] RadioGroup and varible numbers of radio buttons
No, Tapestry will give different ids to your radio tags inside the loop. In the HTML page, a radio belongs to a radiogroup if it has the same "name" parameter, not the same "id". And Tapestry will give a different id but the same "name" to each radio you put in a radiogroup wether it is in a loop or not. Stephane [EMAIL PROTECTED] a écrit : Yes, but within the SAME radio group. I mean: I use it multiple times within the loop? Jens You use the id "radio" 2 times in the same tml page. That's not allowed. Stephane [EMAIL PROTECTED] a écrit : Hi! I have a problem to handle a radiogroup having a variable number of radio buttons created within a loop. The 'tml' looks basically like the following code snippet: value="${loopAddress.userId}"/>${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} this works just fine. After adding a additional radio button outside the loop Tapestry complains that the component with the id "radio" already exists? value="${loopAddress.userId}"/>${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} What is the difference to the loop? So as a workaround I added an empty entry to the address list and preserved the layout by using blocks but I really do not understand why this is not working. Any ideas? Thanks in advance Jens - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup and varible numbers of radio buttons
Yes, but within the SAME radio group. I mean: I use it multiple times within the loop? Jens You use the id "radio" 2 times in the same tml page. That's not allowed. Stephane [EMAIL PROTECTED] a écrit : > Hi! > > I have a problem to handle a radiogroup having a variable number of radio buttons created within a loop. > The 'tml' looks basically like the following code snippet: > > > > > ${loopAddress.userId} > ${loopAddress.firstName} ${loopAddress.lastName} > > > > > this works just fine. > > After adding a additional radio button outside the loop Tapestry complains that the component with the id "radio" already exists? > > > > > ${loopAddress.userId} > ${loopAddress.firstName} ${loopAddress.lastName} > > > > > > What is the difference to the loop? > So as a workaround I added an empty entry to the address list and preserved the layout by using blocks but I really do not understand why this is not working. > > Any ideas? > > Thanks in advance > > Jens > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup and varible numbers of radio buttons
You use the id "radio" 2 times in the same tml page. That's not allowed. Stephane [EMAIL PROTECTED] a écrit : Hi! I have a problem to handle a radiogroup having a variable number of radio buttons created within a loop. The 'tml' looks basically like the following code snippet: ${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} this works just fine. After adding a additional radio button outside the loop Tapestry complains that the component with the id "radio" already exists? ${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} What is the difference to the loop? So as a workaround I added an empty entry to the address list and preserved the layout by using blocks but I really do not understand why this is not working. Any ideas? Thanks in advance Jens - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5] RadioGroup and varible numbers of radio buttons
Hi! I have a problem to handle a radiogroup having a variable number of radio buttons created within a loop. The 'tml' looks basically like the following code snippet: ${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} this works just fine. After adding a additional radio button outside the loop Tapestry complains that the component with the id "radio" already exists? ${loopAddress.userId} ${loopAddress.firstName} ${loopAddress.lastName} What is the difference to the loop? So as a workaround I added an empty entry to the address list and preserved the layout by using blocks but I really do not understand why this is not working. Any ideas? Thanks in advance Jens - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 : RadioGroup Label
Thanks Josh for the issue. I'm a bit puzzled with the comment "Returns null; the radio group does not render as a tag and so doesn't have an id to share". For me, a radiogroup can be replaced by a select and vice versa so the both should be able to have a label. Wouldn't it be possible for a radiogroup to render a simple div as a tag with its id to share ? Stephane Josh Canfield a écrit : Hi Stephane, Looking at the source, the label's id is generated like this: String fieldId = field.getClientId(); _labelElement.forceAttributes("for", fieldId, "id", fieldId + ":label"); If you look at the source for radiogroup you'll see that it is intentionally returning null for the clientId. /** * Returns null; the radio group does not render as a tag and so doesn't have an id to share. RadioGroup implements * [EMAIL PROTECTED] org.apache.tapestry.Field} only so it can interact with the [EMAIL PROTECTED] org.apache.tapestry.ValidationTracker}. * * @return null */ public String getClientId() { return null; } Adding two radiogroups with labels in the page results in label nodes with duplicate id attributes. I've filed the issue here: https://issues.apache.org/jira/browse/TAPESTRY-2255 Josh On Thu, Mar 13, 2008 at 1:50 AM, Stephane Decleire <[EMAIL PROTECTED]> wrote: I forgot to say that i see this behavior on Tap 5.0.11 (i have not try on previous versions) Stephane Stephane Decleire a écrit : I keep on with my conversation alone ... ... and i have just tried to test the code from Tapestry documentation http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Radio.html and get the same result : the label of the radiogroup is not displayed () Has anybody encounter the same behavior ? Should i create a ticket in Jira ? Stephane Stephane Decleire a écrit : I've forgot to give you the result HTML code for the label : Stephane Stephane Decleire a écrit : I can't figure out how to show the label of a RadioGroup ... I have tried what i used to do with other form components without success ... Any idea ? Stephane
Re: T5 : RadioGroup Label
Hi Stephane, Looking at the source, the label's id is generated like this: String fieldId = field.getClientId(); _labelElement.forceAttributes("for", fieldId, "id", fieldId + ":label"); If you look at the source for radiogroup you'll see that it is intentionally returning null for the clientId. /** * Returns null; the radio group does not render as a tag and so doesn't have an id to share. RadioGroup implements * [EMAIL PROTECTED] org.apache.tapestry.Field} only so it can interact with the [EMAIL PROTECTED] org.apache.tapestry.ValidationTracker}. * * @return null */ public String getClientId() { return null; } Adding two radiogroups with labels in the page results in label nodes with duplicate id attributes. I've filed the issue here: https://issues.apache.org/jira/browse/TAPESTRY-2255 Josh On Thu, Mar 13, 2008 at 1:50 AM, Stephane Decleire <[EMAIL PROTECTED]> wrote: > I forgot to say that i see this behavior on Tap 5.0.11 (i have not try > on previous versions) > > > Stephane > > Stephane Decleire a écrit : > > I keep on with my conversation alone ... > > ... and i have just tried to test the code from Tapestry > > documentation > > http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Radio.html > > and get the same result : the label of the radiogroup is not displayed > > () > > Has anybody encounter the same behavior ? > > Should i create a ticket in Jira ? > > > > Stephane > > > > Stephane Decleire a écrit : > >> I've forgot to give you the result HTML code for the label : > >> > >> > >> > >> Stephane > >> > >> Stephane Decleire a écrit : > >>> I can't figure out how to show the label of a RadioGroup ... > >>> I have tried what i used to do with other form components without > >>> success ... > >>> > >>> > >>> >>> t:label="literal:optin-label" t:validate="required"> > >>> > >>> > >>> > >>> > >>> Any idea ? > >>> > >>> Stephane > >>> > >> > > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 : RadioGroup Label
I forgot to say that i see this behavior on Tap 5.0.11 (i have not try on previous versions) Stephane Stephane Decleire a écrit : I keep on with my conversation alone ... ... and i have just tried to test the code from Tapestry documentation http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Radio.html and get the same result : the label of the radiogroup is not displayed () Has anybody encounter the same behavior ? Should i create a ticket in Jira ? Stephane Stephane Decleire a écrit : I've forgot to give you the result HTML code for the label : Stephane Stephane Decleire a écrit : I can't figure out how to show the label of a RadioGroup ... I have tried what i used to do with other form components without success ... t:label="literal:optin-label" t:validate="required"> Any idea ? Stephane
Re: T5 : RadioGroup Label
I keep on with my conversation alone ... ... and i have just tried to test the code from Tapestry documentation http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Radio.html and get the same result : the label of the radiogroup is not displayed () Has anybody encounter the same behavior ? Should i create a ticket in Jira ? Stephane Stephane Decleire a écrit : I've forgot to give you the result HTML code for the label : Stephane Stephane Decleire a écrit : I can't figure out how to show the label of a RadioGroup ... I have tried what i used to do with other form components without success ... t:label="literal:optin-label" t:validate="required"> Any idea ? Stephane
Re: T5 : RadioGroup Label
I've forgot to give you the result HTML code for the label : Stephane Stephane Decleire a écrit : I can't figure out how to show the label of a RadioGroup ... I have tried what i used to do with other form components without success ... t:label="literal:optin-label" t:validate="required"> Any idea ? Stephane
T5 : RadioGroup Label
I can't figure out how to show the label of a RadioGroup ... I have tried what i used to do with other form components without success ... t:label="literal:optin-label" t:validate="required"> Any idea ? Stephane
Re: [T5] RadioGroup
Sorry for my dumb questions. I've been away from java since 1.4 and so I'm not used to play with such magic tricks. Anyway, can I see those values when I do a System.out.println()? I use Eclipse for debugging. Does it make a difference if I set a method breakpoint or a line breakpoint? I'm not on my system right now. But as I can remember when I did debugging with a method breakpoint and stepped through with the debugger the values of all those fields kept null. That's why I'm a little bit surpised. The debugging game seems no longer to be working. I'll try again tomorrow. Thanks Howard, Michael Howard Lewis Ship wrote: > > There's a bit of magic going on. Most of your parameters will be null > except when you have a break point inside code during the rendering of the > component. Further, some of your code will have to read a value from a > parameter field for the field to get filled in. > > Basically, the first time you have code that reads a field value, the > binding object for that field will be invoked to provide the value, and > that > value will be stuff into the field. > > Of course, there's a lot of caching that can go on as well, especially for > string literals and other invariant values. > > On 10/14/07, Michael Gerzabek <[EMAIL PROTECTED]> wrote: >> >> >> Thanks for the advice. I also planned to follow the first path you >> outlined. >> >> It just cost me some time to get familiar with the concept of the inner >> live >> of forms in T5 and I wanted to make a rapid prototype before I would step >> into the definition of a service which is another new area of T5 to me. >> >> But beside this I cannot understand why the parameters from the page are >> not >> filled. I debugged my component and they are all null although the >> ComponentResources _bindings have it. I have no idea why or where to >> look. >> >> What do I miss? >> > -- View this message in context: http://www.nabble.com/-T5--RadioGroup-tf4617856.html#a13202789 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup
There's a bit of magic going on. Most of your parameters will be null except when you have a break point inside code during the rendering of the component. Further, some of your code will have to read a value from a parameter field for the field to get filled in. Basically, the first time you have code that reads a field value, the binding object for that field will be invoked to provide the value, and that value will be stuff into the field. Of course, there's a lot of caching that can go on as well, especially for string literals and other invariant values. On 10/14/07, Michael Gerzabek <[EMAIL PROTECTED]> wrote: > > > Thanks for the advice. I also planned to follow the first path you > outlined. > > It just cost me some time to get familiar with the concept of the inner > live > of forms in T5 and I wanted to make a rapid prototype before I would step > into the definition of a service which is another new area of T5 to me. > > But beside this I cannot understand why the parameters from the page are > not > filled. I debugged my component and they are all null although the > ComponentResources _bindings have it. I have no idea why or where to look. > > What do I miss? > > Michael > > > Howard Lewis Ship wrote: > > > > I would avoid the use of static maps for tracking the radio groups. In > > addition, static will be shared between threads, so you have code that > > will > > likely break in production. > > > > In my book, static should always be stateless. > > > > You have two approaches that work better (and are more testable): > > - Define a service with scope "perthread" as a wrapper around this map > > - Define your own Environmental object. You can make a contribution to > > the > > PageRenderInitializer service to get your environmental object set up. > > > > Generally when you think "I wish PageRenderSupport had such and such a > > method" you can accomplish the same thing by defining your own > > environmental. > > > > > > On 10/14/07, Michael Gerzabek <[EMAIL PROTECTED]> wrote: > >> > >> Sorry, you're right: The component is basically a compilation of Radio > >> and RadioGroup. I use a static Map to secure the unique names of > >> [EMAIL PROTECTED]'s. In setupRender() I prepare the environment in > >> cleanupRender() I wrap it up. > >> > >> Here's the code ... > >> > >> public class Radio implements Field { > >> > >> @Parameter(required = false, defaultPrefix = "literal") > >> private String _id; > >> private String _clientId; > >> > >> @Parameter(defaultPrefix = "literal") > >> private String _label; > >> > >> @Parameter("false") > >> private boolean _disabled; > >> > >> @Parameter(required = false) > >> private ValueEncoder _encoder; > >> > >> @Parameter(required = true, principal = true, > >> defaultPrefix="literal") > >> private Object _value; > >> > >> @Parameter(required = true, defaultPrefix="literal") > >> private String _name; > >> > > > > -- > View this message in context: > http://www.nabble.com/-T5--RadioGroup-tf4617856.html#a13202352 > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Howard M. Lewis Ship Partner and Senior Architect at Feature50 Creator Apache Tapestry and Apache HiveMind
Re: [T5] RadioGroup
Thanks for the advice. I also planned to follow the first path you outlined. It just cost me some time to get familiar with the concept of the inner live of forms in T5 and I wanted to make a rapid prototype before I would step into the definition of a service which is another new area of T5 to me. But beside this I cannot understand why the parameters from the page are not filled. I debugged my component and they are all null although the ComponentResources _bindings have it. I have no idea why or where to look. What do I miss? Michael Howard Lewis Ship wrote: > > I would avoid the use of static maps for tracking the radio groups. In > addition, static will be shared between threads, so you have code that > will > likely break in production. > > In my book, static should always be stateless. > > You have two approaches that work better (and are more testable): > - Define a service with scope "perthread" as a wrapper around this map > - Define your own Environmental object. You can make a contribution to > the > PageRenderInitializer service to get your environmental object set up. > > Generally when you think "I wish PageRenderSupport had such and such a > method" you can accomplish the same thing by defining your own > environmental. > > > On 10/14/07, Michael Gerzabek <[EMAIL PROTECTED]> wrote: >> >> Sorry, you're right: The component is basically a compilation of Radio >> and RadioGroup. I use a static Map to secure the unique names of >> [EMAIL PROTECTED]'s. In setupRender() I prepare the environment in >> cleanupRender() I wrap it up. >> >> Here's the code ... >> >> public class Radio implements Field { >> >> @Parameter(required = false, defaultPrefix = "literal") >> private String _id; >> private String _clientId; >> >> @Parameter(defaultPrefix = "literal") >> private String _label; >> >> @Parameter("false") >> private boolean _disabled; >> >> @Parameter(required = false) >> private ValueEncoder _encoder; >> >> @Parameter(required = true, principal = true, >> defaultPrefix="literal") >> private Object _value; >> >> @Parameter(required = true, defaultPrefix="literal") >> private String _name; >> > -- View this message in context: http://www.nabble.com/-T5--RadioGroup-tf4617856.html#a13202352 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup
I would avoid the use of static maps for tracking the radio groups. In addition, static will be shared between threads, so you have code that will likely break in production. In my book, static should always be stateless. You have two approaches that work better (and are more testable): - Define a service with scope "perthread" as a wrapper around this map - Define your own Environmental object. You can make a contribution to the PageRenderInitializer service to get your environmental object set up. Generally when you think "I wish PageRenderSupport had such and such a method" you can accomplish the same thing by defining your own environmental. On 10/14/07, Michael Gerzabek <[EMAIL PROTECTED]> wrote: > > Sorry, you're right: The component is basically a compilation of Radio > and RadioGroup. I use a static Map to secure the unique names of > [EMAIL PROTECTED]'s. In setupRender() I prepare the environment in > cleanupRender() I wrap it up. > > Here's the code ... > > > package com.michaelgerzabek.services.web.components; > > import java.util.HashMap; > import java.util.Map; > > import org.apache.tapestry.Binding; > import org.apache.tapestry.ComponentAction; > import org.apache.tapestry.ComponentResources; > import org.apache.tapestry.Field; > import org.apache.tapestry.MarkupWriter; > import org.apache.tapestry.PageRenderSupport; > import org.apache.tapestry.RadioContainer; > import org.apache.tapestry.ValueEncoder; > import org.apache.tapestry.annotations.Environmental; > import org.apache.tapestry.annotations.Parameter; > import org.apache.tapestry.internal.TapestryInternalUtils; > import org.apache.tapestry.ioc.annotations.Inject; > import org.apache.tapestry.services.ComponentDefaultProvider; > import org.apache.tapestry.services.Environment; > import org.apache.tapestry.services.FormSupport; > import org.apache.tapestry.services.Request; > import org.apache.tapestry.services.ValueEncoderSource; > > public class Radio implements Field { > > @Parameter(required = false, defaultPrefix = "literal") > private String _id; > private String _clientId; > > @Parameter(defaultPrefix = "literal") > private String _label; > > @Parameter("false") > private boolean _disabled; > > @Parameter(required = false) > private ValueEncoder _encoder; > > @Parameter(required = true, principal = true, defaultPrefix="literal") > private Object _value; > > @Parameter(required = true, defaultPrefix="literal") > private String _name; > > public String getElementName() { > > return _name; > } > > @Inject > private ComponentDefaultProvider _defaultProvider; > > @Inject > private ValueEncoderSource _valueEncoderSource; > > String defaultLabel() { > > return _defaultProvider.defaultLabel( _resources ); > } > > Binding defaultValue() { > > return _defaultProvider.defaultBinding( "value", _resources ); > } > > final ValueEncoder defaultEncoder() { > > return _valueEncoderSource.createEncoder( "value", _resources ); > } > > public String getLabel() { > > return _label; > } > > public boolean isDisabled() { > > return _disabled; > } > > public String getClientId() { > > return _clientId; > } > > @Inject > private PageRenderSupport _pageRenderSupport; > > /** > * Markup generieren für <[EMAIL PROTECTED]/> > */ > > void beginRender( MarkupWriter writer ) { > > RadioContainer _container = _environment.peek( > RadioContainer.class ); > String value = _container.toClient( _value ); > > _clientId = _pageRenderSupport.allocateClientId( _id ); > _name = _container.getElementName(); > > writer.element( > "input", > "type", > "radio", > "id", > _clientId, > "name", > _name, > "value", > value); > > if ( _container.isSelected( _value ) ) writer.attributes( > "checked", "checked" ); > } > > void afterRender( MarkupWriter writer ) { > > writer.end(); > } > > /** > * Die Container-Organisation > */ > private static Map radioGroups = new > HashMap(); > > @Environmental > private FormSupport _formSupport; > > @Inject > private Environment _environment; > > @Inject > private ComponentResources _resources; > > @Inject > private Request _request; > > private Object _clientValue; > > private void setup( String elementName ) { > > _name = elementName; > } > > private void processSubmission() { > > String clientValue = _request.getParameter( _name ); > > Object value = _encoder.toValue( clientValue ); > > _clientValue = value;
Re: [T5] RadioGroup
Sorry, you're right: The component is basically a compilation of Radio and RadioGroup. I use a static Map to secure the unique names of [EMAIL PROTECTED]'s. In setupRender() I prepare the environment in cleanupRender() I wrap it up. Here's the code ... package com.michaelgerzabek.services.web.components; import java.util.HashMap; import java.util.Map; import org.apache.tapestry.Binding; import org.apache.tapestry.ComponentAction; import org.apache.tapestry.ComponentResources; import org.apache.tapestry.Field; import org.apache.tapestry.MarkupWriter; import org.apache.tapestry.PageRenderSupport; import org.apache.tapestry.RadioContainer; import org.apache.tapestry.ValueEncoder; import org.apache.tapestry.annotations.Environmental; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.internal.TapestryInternalUtils; import org.apache.tapestry.ioc.annotations.Inject; import org.apache.tapestry.services.ComponentDefaultProvider; import org.apache.tapestry.services.Environment; import org.apache.tapestry.services.FormSupport; import org.apache.tapestry.services.Request; import org.apache.tapestry.services.ValueEncoderSource; public class Radio implements Field { @Parameter(required = false, defaultPrefix = "literal") private String _id; private String _clientId; @Parameter(defaultPrefix = "literal") private String _label; @Parameter("false") private boolean _disabled; @Parameter(required = false) private ValueEncoder _encoder; @Parameter(required = true, principal = true, defaultPrefix="literal") private Object _value; @Parameter(required = true, defaultPrefix="literal") private String _name; public String getElementName() { return _name; } @Inject private ComponentDefaultProvider _defaultProvider; @Inject private ValueEncoderSource _valueEncoderSource; String defaultLabel() { return _defaultProvider.defaultLabel( _resources ); } Binding defaultValue() { return _defaultProvider.defaultBinding( "value", _resources ); } final ValueEncoder defaultEncoder() { return _valueEncoderSource.createEncoder( "value", _resources ); } public String getLabel() { return _label; } public boolean isDisabled() { return _disabled; } public String getClientId() { return _clientId; } @Inject private PageRenderSupport _pageRenderSupport; /** * Markup generieren für <[EMAIL PROTECTED]/> */ void beginRender( MarkupWriter writer ) { RadioContainer _container = _environment.peek( RadioContainer.class ); String value = _container.toClient( _value ); _clientId = _pageRenderSupport.allocateClientId( _id ); _name = _container.getElementName(); writer.element( "input", "type", "radio", "id", _clientId, "name", _name, "value", value); if ( _container.isSelected( _value ) ) writer.attributes( "checked", "checked" ); } void afterRender( MarkupWriter writer ) { writer.end(); } /** * Die Container-Organisation */ private static Map radioGroups = new HashMap(); @Environmental private FormSupport _formSupport; @Inject private Environment _environment; @Inject private ComponentResources _resources; @Inject private Request _request; private Object _clientValue; private void setup( String elementName ) { _name = elementName; } private void processSubmission() { String clientValue = _request.getParameter( _name ); Object value = _encoder.toValue( clientValue ); _clientValue = value; } private static class Setup implements ComponentAction { private static final long serialVersionUID = -7984673040135949374L; private final String _elementName; Setup( String elementName ) { _elementName = elementName; } public void execute( Radio component ) { component.setup( _elementName ); } }; private static final ComponentAction PROCESS_SUBMISSION = new ComponentAction() { private static final long serialVersionUID = -3857110108918776386L; public void execute( Radio component ) { component.processSubmission(); } }; /** * Environment herstellen */ final void setupRender() { String name = _formSupport.allocateElementName( _resources.getElementName() ); RadioContainer radioContainer = radioGroups.get( name ); if ( n
Re: [T5] RadioGroup
Hard to say without seeing the source and how you are using the component. Cheers, Nick. Michael Gerzabek wrote: I implemented an alternative radio component. When I debug my setupRender() the parameters from the template are all null. When I look into the ComponentResources in _bindings there are all my Parameters but the annotated values in my own component seem never be initialized. What am am I missing? Regards, Michael Nick Westgate schrieb: The obvious answer to your question is the source for RadioGroup.java. ;-) http://tapestry.apache.org/tapestry5/apidocs/src-html/org/apache/tapestry/corelib/components/RadioGroup.html Basically, RadioGroup is responsible for the collective behaviour of Radios when each is rendering, and when the form is submitted, through RadioContainer "Environmentals" stored in the Environment service: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/RadioContainer.html http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/services/Environment.html When you understand how this class behaves, you could consider moving the functionality into either a new Radio component or possibly into a new Form component - though Form is quite complex already. Yet another approach, since you are already preprocessing the html, would be to automatically insert RadioGroups where necessary. If you come up with an interesting solution, please let the list know. Cheers, Nick. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup
I implemented an alternative radio component. When I debug my setupRender() the parameters from the template are all null. When I look into the ComponentResources in _bindings there are all my Parameters but the annotated values in my own component seem never be initialized. What am am I missing? Regards, Michael Nick Westgate schrieb: The obvious answer to your question is the source for RadioGroup.java. ;-) http://tapestry.apache.org/tapestry5/apidocs/src-html/org/apache/tapestry/corelib/components/RadioGroup.html Basically, RadioGroup is responsible for the collective behaviour of Radios when each is rendering, and when the form is submitted, through RadioContainer "Environmentals" stored in the Environment service: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/RadioContainer.html http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/services/Environment.html When you understand how this class behaves, you could consider moving the functionality into either a new Radio component or possibly into a new Form component - though Form is quite complex already. Yet another approach, since you are already preprocessing the html, would be to automatically insert RadioGroups where necessary. If you come up with an interesting solution, please let the list know. Cheers, Nick. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] RadioGroup
The obvious answer to your question is the source for RadioGroup.java. ;-) http://tapestry.apache.org/tapestry5/apidocs/src-html/org/apache/tapestry/corelib/components/RadioGroup.html Basically, RadioGroup is responsible for the collective behaviour of Radios when each is rendering, and when the form is submitted, through RadioContainer "Environmentals" stored in the Environment service: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/RadioContainer.html http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/services/Environment.html When you understand how this class behaves, you could consider moving the functionality into either a new Radio component or possibly into a new Form component - though Form is quite complex already. Yet another approach, since you are already preprocessing the html, would be to automatically insert RadioGroups where necessary. If you come up with an interesting solution, please let the list know. Cheers, Nick. Michael Gerzabek wrote: Hi, I'm new to tapestry and started with T5. It's awesome stuff! With the tutorial, the maven archetype and a few hints from the wiki and the mailing list startup was straight forward. Compared to many other frameworks this is really one of the BIGGEST advantages of T5. Great job guys!!! I'm working on a small technology spike to get new directions in developing webapps in future. It is important for me to have a clear separation between the different roles in projects. One role is the graphic designers. They have to provide the whole xhtml stuff. Our customer likes to have the fancy features also in their logic pages. So we try to give them what they want making our lives easier. On the other side there ist the role of the web developers. They need to put those inanimate pages into exist and gather the user conversations. The T5 programming model does a brilliant job here. I love Howard's quote "... pages are facilitators ..." from one of the screencasts. The last role of course is the one of the backend people. So what we primarily do is we take those inanimate xhtml pages and guide them through an xsl stylesheet transformation to prepare tapestry markup. It work's really nice. T5 does a very nice separation of concerns out of the box here. At the time there's only one small bump when it comes from using those pages the designer gives us to .tml. And it's the use of radiobuttons. People are used to group different radiobuttons simply by giving them the same name. T5 requires the newly introduced tag t:RadioGroup to group radiobuttons that belong together. So my question is, where do I have to look to get an idea of how to implement my own t:Radio tag that automagically creates a new t:RadioGroup for each occurence of a new groupname? Michael -- "Path is created through walking" [winged words] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5] RadioGroup
Hi, I'm new to tapestry and started with T5. It's awesome stuff! With the tutorial, the maven archetype and a few hints from the wiki and the mailing list startup was straight forward. Compared to many other frameworks this is really one of the BIGGEST advantages of T5. Great job guys!!! I'm working on a small technology spike to get new directions in developing webapps in future. It is important for me to have a clear separation between the different roles in projects. One role is the graphic designers. They have to provide the whole xhtml stuff. Our customer likes to have the fancy features also in their logic pages. So we try to give them what they want making our lives easier. On the other side there ist the role of the web developers. They need to put those inanimate pages into exist and gather the user conversations. The T5 programming model does a brilliant job here. I love Howard's quote "... pages are facilitators ..." from one of the screencasts. The last role of course is the one of the backend people. So what we primarily do is we take those inanimate xhtml pages and guide them through an xsl stylesheet transformation to prepare tapestry markup. It work's really nice. T5 does a very nice separation of concerns out of the box here. At the time there's only one small bump when it comes from using those pages the designer gives us to .tml. And it's the use of radiobuttons. People are used to group different radiobuttons simply by giving them the same name. T5 requires the newly introduced tag t:RadioGroup to group radiobuttons that belong together. So my question is, where do I have to look to get an idea of how to implement my own t:Radio tag that automagically creates a new t:RadioGroup for each occurence of a new groupname? Michael -- "Path is created through walking" [winged words] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: radiogroup, label BUG?
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 I get the exception about no RadioContainer! Using a raw 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: xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> Type 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]