gpt4 book ai didi

java - ADF : Calling a method through a managed beans in JSP

转载 作者:行者123 更新时间:2023-11-30 05:15:12 25 4
gpt4 key购买 nike

我在向 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 有任何建议吗?

最佳答案

#{pageFlowScope.customerFacadeBean.test['test1', 'test2']}

这不是合法的统一表达语言表达式。你可能可以这样做:

#{pageFlowScope.customerFacadeBean.test['test1']['test2']}

...其中 test 解析为 map 的 map :

  public Map<Object, Map<Object, Object>> getTest() {
return new HashMap<Object, Map<Object, Object>>() {
@Override
public Map<Object, Object> get(final Object test1) {
return new HashMap<Object, Object>() {
@Override
public Object get(Object test2) {
return getSomething(test1, test2);
}
};
}
};
}

private Object getSomething(Object test1, Object test2) {
//TODO
}

显然,这真的很难看。

你可以尝试implementing a custom function格式为 #{stuff:callTest(pageFlowScope.customerFacadeBean, 'test1', 'test2')}

实现 JSP 2.1 Maintenance Release 2 的服务器应支持 #{mybean.something(param)} ( read this for more info ) 形式的表达式。某些框架可能已经支持此语法 - 值得检查文档。

关于java - ADF : Calling a method through a managed beans in JSP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1695492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com