ADF:通过 JSP 中的托管 bean 调用方法
我在向 Oracle ADF 内的 JSP 中的托管 bean 传递参数时遇到问题。这是一个示例 JSP 测试页,我试图将参数传递给 POJO 中的测试方法:
<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=windows-1252"/>
<f:view>
<af:document title="Automated Scheduling Tool > Customer Portal > Packages"
id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<center>
<br/><br/><br/>
<table cellspacing="0" cellpadding="45" width="800">
<tr>
<td width="100%" class="darkBackground">
<span class="largeTitle">AUTOMATED SCHEDULING TOOL</span>
<br/>
<span class="mediumTitle">CUSTOMER PORTAL</span>
</td>
</tr>
<tr>
<af:outputText value="#{pageFlowScope.customerFacadeBean.test['test1', 'test2']}" id="ot1" />
</tr>
</table>
</center>
</af:form>
</af:document>
</f:view>
</jsp:root>
public class CustomerFacade {
private final PackageMapper mapper;
private List<Package> packages;
public CustomerFacade() {
mapper = new PackageMapper();
packages = mapper.findAllPackages();
}
public List<Package> getPackages() {
return packages;
}
public String test(String testString1, String testString2){
System.out.println(testString1 + testString2);
return "Success!";
}
}
有人对如何通过托管 bean 将参数传递给 POJO 有任何建议吗?
I am running into issues with passing parameters to managed beans in JSP within Oracle ADF. Here is an example JSP test page I am trying to pass parameters to a test method in a POJO:
<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=windows-1252"/>
<f:view>
<af:document title="Automated Scheduling Tool > Customer Portal > Packages"
id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<center>
<br/><br/><br/>
<table cellspacing="0" cellpadding="45" width="800">
<tr>
<td width="100%" class="darkBackground">
<span class="largeTitle">AUTOMATED SCHEDULING TOOL</span>
<br/>
<span class="mediumTitle">CUSTOMER PORTAL</span>
</td>
</tr>
<tr>
<af:outputText value="#{pageFlowScope.customerFacadeBean.test['test1', 'test2']}" id="ot1" />
</tr>
</table>
</center>
</af:form>
</af:document>
</f:view>
</jsp:root>
public class CustomerFacade {
private final PackageMapper mapper;
private List<Package> packages;
public CustomerFacade() {
mapper = new PackageMapper();
packages = mapper.findAllPackages();
}
public List<Package> getPackages() {
return packages;
}
public String test(String testString1, String testString2){
System.out.println(testString1 + testString2);
return "Success!";
}
}
Does anyone have any suggestions for how I can pass parameters to the POJO via a managed bean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是合法的统一表达语言表达式。你可能会做这样的事情:
...其中
test
解析为地图的地图:显然,这真的很难看。
您可以尝试实现自定义函数表单
#{stuff:callTest(pageFlowScope.customerFacadeBean, 'test1', 'test2')}
。实现 JSP 2.1 Maintenance Release 2 的服务器应该支持以下表达式形式
#{mybean.something(param)}
(阅读本文以获取更多信息)。一些框架可能已经支持这种语法 - 值得检查文档。This is not a legal Unified Expression Language expression. You could probably do something like this:
...where
test
resolved to a map of maps:Obviously, this is really ugly.
You could try implementing a custom function in the form
#{stuff:callTest(pageFlowScope.customerFacadeBean, 'test1', 'test2')}
.Servers implementing JSP 2.1 Maintenance Release 2 should support expressions of the form
#{mybean.something(param)}
(read this for more info). Some frameworks may already support this syntax - it's worth checking the doc.有一个类似于上面的优雅的替代解决方案: http://wiki.apache.org/myfaces/ EL函数中的参数
There is a somewhat elegant alternative solution similar to the above: http://wiki.apache.org/myfaces/Parameters_In_EL_Functions