Md. Mahabubur Rahman
Md. Mahabubur Rahman

Reputation: 820

How to access value from resource bundle using on the fly (dynamic) generated key

i declared a variable named item

and create a bundle. it contain some data as follow

StudentAdd=student/Create.xhtml
StudentEdit=student/Edit.xhtml
StudentList=student/List.xhtml
DepartmentAdd=department/Create.xhtml

i want to include different xhtml page by the change of variable data

here is my xhtml code

<c:forEach items="#{ajaxBean.chcekItem}" var="item" varStatus="loop">
                    <p:tab id="#{item}" title="#{item}" closable="true">                            
                        <ui:include src="#{bundle.#{item}}"/>   

                    </p:tab>
                </c:forEach>

i can try above way but show following error message ...

/index.xhtml @57,66 src="#{bundle.#{item}}" The identifier [#] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.

Upvotes: 2

Views: 981

Answers (1)

Daniel
Daniel

Reputation: 37051

instead of <ui:include src="#{bundle.#{item}}"/>

use <ui:include src="#{bundle[item]}"/>

Upvotes: 1

Related Questions