This content has been marked as final.
Show 5 replies
-
1. Re: How to Inject app properties to bean transient method
fernando_jmt Mar 19, 2007 8:45 AM (in response to statelessbean)I think the 1 approach it is ok.
I have working something similar:<ice:selectManyCheckbox value="#{userManager.userRoles}" id="userRoles"> <s:selectItems value="#{roleList.resultList}" var="role" label="#{messages[role.description]}"/> </ice:selectManyCheckbox>
As you can see I get the property value for role.description on the fly using the messages. -
2. Re: How to Inject app properties to bean transient method
statelessbean Mar 19, 2007 9:38 AM (in response to statelessbean)That's not exacly i want to...
look:
My Entity Bean looks like this:
private int howOld;
private boolean sex;@Transient public String getPersonName() { if(sex) { switch(howOld) { case(20) : //And here i want to get some text from app properties like example: messages.get('sex.youngMane'); <-----here i want to Inject some string break: ..... } } }
-
3. Re: How to Inject app properties to bean transient method
pmuir Mar 19, 2007 10:40 AM (in response to statelessbean)<h:column> <h:outputText value="#{messages['sex.youngMane']}" rendered="#{entity.sex and entity.howOld eq 20}" /> </h:column>
-
4. Re: How to Inject app properties to bean transient method
sherkan777 Mar 20, 2007 8:20 AM (in response to statelessbean)"petemuir" wrote:
<h:column> <h:outputText value="#{messages['sex.youngMane']}" rendered="#{entity.sex and entity.howOld eq 20}" /> </h:column>
Isn't better to get string directly from method?
Maybe u not understod my think.
I have field like int in each entity bean and collection of those beans.
and iterating my collection on page i want to get from application resources some string, dependent of my int flag.
likepublic int getAge() { .... } @Transient public String getName() { int age = getAge(); String tempString = ""; switch(age) { case(1) : tempString = messages.("age.veryYoung"); break; case(2) : tempString = messages.("age.twoYearsOld"); break; } return tempString; } and in <h:dataTable <h:column> <h:outputText value="currentBean.name" /> </h:column>
-
5. Re: How to Inject app properties to bean transient method
pmuir Mar 20, 2007 9:28 AM (in response to statelessbean)I understand :) I wouldn't want to mix my business and presentation logic like you suggest, so I would keep the presentation logic in the page. You could of course do what you suggest as well.