1

Background

A managed bean must have parameters configured through its web.xml file. The web.xml file defines context initialization parameters that are configured in JDeveloper (11.1.2.3) as follows:

enter image description here

The source for the definition of reporting.server.protocol follows:

  <context-param>
    <description>Defines the data transport mechanism to ret...</description>
    <param-name>reporting.server.protocol</param-name>
    <param-value>http</param-value>
  </context-param>

The bean exposes public accessor methods for reportServerProtocol.

The source for the bean resembles:

@ManagedBean
@RequestScoped
public class OracleReportBean extends ReportBean {

  @ManagedProperty("#{initParam['reporting.server.protocol']}")
  private String reportServerProtocol = URLReportImpl.DEFAULT_PROTOCOL;

  // ...
}

Problem

I would like to initialize the bean using context initialization parameters, rather than through FacesContext. In adfc-config.xml (note: not faces-confg.xml), some examples show references to initParam:

<managed-bean>
  <managed-bean-name>reportBean</managed-bean-name>
  <managed-bean-class>ca.corp.report.view.OracleReportBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
    <property-name>reportServerProtocol</property-name>
    <property-class>java.lang.String</property-class>
    <value>#{initParam['reporting.server.protocol']}</value>
  </managed-property>
...
</managed-bean>

The key line being the value element #{initParam['reporting.server.protocol']}. However, JDeveloper shows the line as being incorrect. That is, the initParam context is not available within adfc-confing.xml.

The error is: "EL token initParam is unknown."

Question

Using an EL, how can the context initialization parameters be used to configure a managed bean, declaratively within ADFc?

Related Links

Community
  • 1
  • 1
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315

2 Answers2

1

A bug in JDeveloper causes errors to be displayed:

JDeveloper Error

However, even though the IDE displays an error, the code executes as expected.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
0

In the ui layer you could try something like this :

<c:set target="${BeanName}" property="PropertyName" value="${true}"/>
lokoko
  • 5,785
  • 5
  • 35
  • 68