This content has been marked as final.
Show 9 replies
-
1. Re: How to double indirect a label (seam question)
pmuir Apr 13, 2007 5:09 PM (in response to tony.herstell1)@Factory("advertType") public AdvertType[] getAdvertTypes() { return AdvertType.values(); }
<h:selectOneRadio id="advertType" value="#{advertisingCampaignController.campaign.advert.type}"> <s:selectItems value="#{advertTypes}" var="advertType" label="#{messages['label_ad_type_'advertType]}"/> <s:convertEnum /> </h:selectOneRadio>
Though I'm not sure concating the string for the message key like that is valid . -
2. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 5:41 PM (in response to tony.herstell1)<s:decorate> <h:selectOneRadio id="advertType" required="true" value="#{advertisingCampaignController.campaign.advert.type}"> <s:selectItems value="#{advertisingCampaignController.campaign.advert.advertTypes}" var="advertType" label="advertType"> <s:convertEnum /> </s:selectItems> </h:selectOneRadio> </s:decorate>
givesSEVERE: Error Rendering View[/pages/advertisingCampaign/wizard.xhtml] com.sun.facelets.tag.TagException: /WEB-INF/pages/advertisingCampaignWizard/adType.xhtml @25,28 <s:convertEnum> Parent not an instance of ValueHolder: org.jboss.seam.ui.UISelectItems@6ba6895c
????
and you were right:label="#{messages['label_ad_type_'advertType]}"
didnt work
:( -
3. Re: How to double indirect a label (seam question)
pmuir Apr 13, 2007 5:53 PM (in response to tony.herstell1)Put the s:convertEnum as direct child of the h:selectOneRadio as I did.
#{messages[advertType]} will work, alternatively, put a property on the Enum which contains the key e.g. #{messages[advertType.key]} -
4. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 5:54 PM (in response to tony.herstell1)This seemed to get rid of the error (using a list (no I dont know why))...
still cant get the label to work.
Any ideas?@Transient public List<String> getAdvertTypes() { List<String> advertTypesAsStringList = new ArrayList<String>(); AdvertType[] advertTypesAsStringArray = AdvertType.values(); for (AdvertType type : advertTypesAsStringArray) { advertTypesAsStringList.add(type.toString()); } return advertTypesAsStringList; }
-
5. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 5:55 PM (in response to tony.herstell1)"petemuir" wrote:
Put the s:convertEnum as direct child of the h:selectOneRadio as I did.
#{messages[advertType]} will work, alternatively, put a property on the Enum which contains the key e.g. #{messages[advertType.key]}
trying that now -
6. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 6:05 PM (in response to tony.herstell1)>> java.lang.String cannot be cast to java.lang.Enum
I think I did what you said...
From Advert entity:@Transient public AdvertType[] getAdvertTypes() { return AdvertType.values(); }
<h:selectOneRadio id="advertType" required="true" value="#{advertisingCampaignController.campaign.advert.type}"> <s:selectItems value="#{advertisingCampaignController.campaign.advert.advertTypes}" var="advertType" label="#{messages[advertType]}"/> <s:convertEnum /> </h:selectOneRadio>
-
7. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 6:56 PM (in response to tony.herstell1)Pete, your kung foo is strong:
public enum AdvertType { Lineage ("label_ad_type_lineage"), BannerAd ("label_ad_type_banner_ad"); private final String label; AdvertType(String label) { this.label = label; } public String getLabel() { return label; } }
@NotNull(message="required") @Length(max = 30) public AdvertType getType() { return type; } public void setType(AdvertType type) { this.type = type; }
<h:selectOneRadio id="advertType" required="true" value="#{advertisingCampaignController.campaign.advert.type}"> <s:selectItems value="#{advertisingCampaignController.campaign.advert.advertTypes}" var="advertType" label="#{messages[advertType.label]}"/> <s:convertEnum /> </h:selectOneRadio>
Thanyou for your suppoort and pointing me in the right direction (I didnt even know Emuns could have "parameters"!
-
8. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 6:57 PM (in response to tony.herstell1)Oh yes and this bit.
@Transient public AdvertType[] getAdvertTypes() { return AdvertType.values(); }
-
9. Re: How to double indirect a label (seam question)
tony.herstell1 Apr 13, 2007 9:05 PM (in response to tony.herstell1)Darn..
If I use a validateAll for the whole form I get:
>>> java.lang.String cannot be cast to java.lang.Enum<h:selectOneRadio id="advertType" required="true" value="#{advertisingCampaignController.campaign.advert.type}"> <s:selectItems value="#{advertisingCampaignController.campaign.advert.advertTypes}" var="advertType" label="#{messages[advertType.label]}"/> <s:convertEnum /> <s:validate/> </h:selectOneRadio>
For now, (after finding the problem!), I have just added <s:validate/> to all the other fields.
Is this a JIRA issue?