Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing dynamic resource message

In my Jsp i am having radio buttons for

typeA

typeB

typeC

typeD 

I have used following tag :

<c:forEach var="abcTyp" items="${abcTypeList}">
    <form:radiobutton path="abcType" value="<spring:message code="label.admin.lot.${abcType.value}" />" label="${abcTyp.value}" onclick="actSingStone();"/>
</c:forEach>

but instead of using "abcTyp.value" as a label,i want to use internationalized message form resource bundle .

I tried using

<form:radiobuttons path="abcType" value="${abcTypeList}" label="<spring:message code="label.admin.pep.${abcTyp.value}"/>." onclick="actSingStone();"/>

in my resource file i have mentioned

label.admin.pep.typeA = some text
label.admin.pep.typeB = some text
label.admin.pep.typeC = some text
label.admin.pep.typeD = some text

but it's giving an error "equal symbol expected"

Can anybody give me solution for the same....??

like image 657
JOHND Avatar asked Mar 26 '26 02:03

JOHND


1 Answers

Try setting the label to variable and use it, like below

<c:forEach var="abcTyp" items="${abcTypeList}">
  <c:set var="labelVar">
      <spring:message code="label.admin.lot.${abcType.value}" />
  </c:set>    
  <form:radiobutton path="abcType" label="${labelVar}" value="${abcTyp.value}" onclick="actSingStone();"/>    
</c:forEach>
like image 115
jmj Avatar answered Mar 28 '26 16:03

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!