jsp:包含职位问题
我对jsp动态包含有一个问题。 换句话说,我有一个用于模板化的主jsp,它包括两个其他jsp。 包含的jsp包含SAP hbj taglibrary,主jsp是纯jsp(1.2)代码 问题是,包含的JSP不遵守运行时的呈现顺序,但它们是在页面顶部呈现的。 我读了一些关于这方面的文章,但我没有找到解决办法 你能帮帮我吗 谢谢jsp:包含职位问题,jsp,include,Jsp,Include,我对jsp动态包含有一个问题。 换句话说,我有一个用于模板化的主jsp,它包括两个其他jsp。 包含的jsp包含SAP hbj taglibrary,主jsp是纯jsp(1.2)代码 问题是,包含的JSP不遵守运行时的呈现顺序,但它们是在页面顶部呈现的。 我读了一些关于这方面的文章,但我没有找到解决办法 你能帮帮我吗 谢谢 // Primo CASO: // Compiling Exception: // • No renderer context available (a htm
// Primo CASO:
// Compiling Exception:
// • No renderer context available (a htmlb tag without a rendererContext attribute must be nested within a RendererContext tag)
// masterPage.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<div>
<p>IncludedPage1 Start</p>
<jsp:include page="includedPage1.jsp" />
<p>IncludedPage1 End</p>
<p>IncludedPage2 Start</p>
<jsp:include page="includedPage2.jsp" />
<p>IncludedPage2 End</p>
<p>IncludedPage3 Start</p>
<jsp:include page="includedPage3.jsp" />
<p>IncludedPage3 End</p>
</div>
<div>
<h3><%="MyBean: " + myBean.toString()%></h3>
</div>
</hbj:form>
</hbj:page>
</hbj:content>
//includedPage1.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<div class="radioCheck_elementContainer">
<hbj:radioButtonGroup id="fldUteRegistrato" columnCount="2" selection="<%=myBean.getRadioButtonValue()%>">
<%fldUteRegistrato.setOnClick("onClickRadio");%>
<hbj:radioButton id="fldUteRegistratoSI" text="SI" key="SI" tooltip="Registrato" disabled="FALSE" />
<hbj:radioButton id="fldUteRegistratoNO" text="NO, procedere alla registrazione sul sito Poste.it da parte del Cointestatario" key="NO" tooltip="Non Registrato" disabled="FALSE" />
<hbj:radioButton id="fldUteRegistratoNULL" text="NULL VALUE" key="NULL" tooltip="NULL VALUE" disabled="FALSE" />
</hbj:radioButtonGroup>
</div>
//includedPage2.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<% String ifldId = ""; %>
<hbj:inputField id="fldInputFieldPage2" type="string" maxlength="16" value="">
<% ifldId = myContext.getParamIdForComponent(fldInputFieldPage2); %>
</hbj:inputField>
<script type="text/javascript">
alert("ID CAMPO:" + <%=ifldId%>)
</script>
//includedPage3.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<hbj:inputField id="fldInputField" type="string" maxlength="16" value="" />
<% String avanti="";%>
<hbj:button id="cmdAvanti" text="Avanti" width="127" onClick="onCmdAvanti" design="EMPHASIZED" encode="True">
<%
avanti = myContext.getParamIdForComponent(cmdAvanti);
%>
</hbj:button>
<script type="text/javascript">
alert("ID Pulsante:" + <%=avanti%>)
</script>
// Secondo CASO:
// Exception:
// • Nessuna
// Comportamento:
// • Solo I campi appartenenti al form da cui parte l’evento vengono inviati al server, la causa è la creazione di più form e quindi di conseguenza nell’HTTP request trovo solo i campi del form da cui è staqto effettuato il submit (Evento)
// masterPage.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<div>
<p>IncludedPage1 Start</p>
<jsp:include page="includedPage1.jsp" flush="true" />
<p>IncludedPage1 End</p>
<p>IncludedPage2 Start</p>
<jsp:include page="includedPage2.jsp" flush="true" />
<p>IncludedPage2 End</p>
<p>IncludedPage3 Start</p>
<jsp:include page="includedPage3.jsp" flush="true" />
<p>IncludedPage3 End</p>
</div>
<div>
<h3><%="MyBean: " + myBean.toString()%></h3>
</div>
//includedPage1.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<hbj:content id="myContext1" >
<hbj:page title="PageTitle1">
<hbj:form id="myFormId" >
<div class="radioCheck_elementContainer">
<hbj:radioButtonGroup id="fldUteRegistrato" columnCount="2" selection="<%=myBean.getRadioButtonValue()%>">
<%fldUteRegistrato.setOnClick("onClickRadio");%>
<hbj:radioButton id="fldUteRegistratoSI" text="SI" key="SI" tooltip="Registrato" disabled="FALSE" />
<hbj:radioButton id="fldUteRegistratoNO" text="NO, procedere alla registrazione sul sito Poste.it da parte del Cointestatario" key="NO" tooltip="Non Registrato" disabled="FALSE" />
<hbj:radioButton id="fldUteRegistratoNULL" text="NULL VALUE" key="NULL" tooltip="NULL VALUE" disabled="FALSE" />
</hbj:radioButtonGroup>
</div>
</hbj:form>
</hbj:page>
</hbj:content>
includedPage2.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<hbj:content id="myContext2" >
<hbj:page title="PageTitle2">
<hbj:form id="myFormId" >
<% String ifldId = ""; %>
<hbj:inputField id="fldInputFieldPage2" type="string" maxlength="16" value="<%=myBean.getInputFieldValuePage2()%>">
<% ifldId = myContext2.getParamIdForComponent(fldInputFieldPage2); %>
</hbj:inputField>
<script type="text/javascript">
alert("ID CAMPO:" + <%=ifldId%>)
</script>
</hbj:form>
</hbj:page>
</hbj:content>
//includedPage3.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="session" class="include.test.bean.MyBean" />
<hbj:content id="myContext3" >
<hbj:page title="PageTitle3">
<hbj:form id="myFormId" >
<hbj:inputField id="fldInputField" type="string" maxlength="16" value="<%=myBean.getInputFieldValue()%>" />
<% String avanti="";%>
<hbj:button id="cmdAvanti" text="Avanti" width="127" onClick="onCmdAvanti" design="EMPHASIZED" encode="True">
<%
avanti = myContext3.getParamIdForComponent(cmdAvanti);
%>
</hbj:button>
<script type="text/javascript">
alert("ID Pulsante:" + <%=avanti%>)
</script>
</hbj:form>
</hbj:page>
</hbj:content>
<script type="text/javascript">
alert("ID Pulsante:" + <%=avanti%>)
</script>
// Appendice:
// MasterPage.java
package include.test;
import include.test.bean.MyBean;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;
import com.sapportals.htmlb.event.*;
import com.sapportals.htmlb.page.*;
import com.sapportals.portal.htmlb.page.*;
import com.sapportals.portal.prt.component.*;
public class MasterPage extends PageProcessorComponent {
public DynPage getPage() {
return new MasterPageDynPage();
}
public static class MasterPageDynPage extends JSPDynPage {
private MyBean myBean = null;
private void initBean() {
IPortalComponentSession componentSession =
((IPortalComponentRequest) getRequest()).getComponentSession();
Object o = componentSession.getValue("myBean");
if (o == null || !(o instanceof MyBean)) {
myBean = new MyBean();
componentSession.putValue("myBean", myBean);
} else {
myBean = (MyBean) o;
}
}
public void doInitialization() {
IPortalComponentSession componentSession =
((IPortalComponentRequest) getRequest()).getComponentSession();
Object o = componentSession.getValue("myBean");
if (o == null || !(o instanceof MyBean)) {
myBean = new MyBean();
componentSession.putValue("myBean", myBean);
} else {
myBean = (MyBean) o;
}
myBean.setMethod("doInitialization");
}
public void doProcessAfterInput() throws PageException {
initBean();
InputField ifld = (InputField) getComponentByName("fldInputField");
if(ifld!=null && ifld.getValue()!=null) {
myBean.setInputFieldValue(ifld.getValue().toString());
}
else {
myBean.setInputFieldValue("NULL VALUE");
}
RadioButtonGroup radioButtonGroup = (RadioButtonGroup) getComponentByName("fldUteRegistrato");
if(radioButtonGroup!=null && radioButtonGroup.getSelection()!=null) {
myBean.setRadioButtonValue(radioButtonGroup.getSelection());
}
else {
myBean.setRadioButtonValue("NULL");
}
InputField ifld2 = (InputField) getComponentByName("fldInputFieldPage2");
if(ifld2!=null && ifld2.getValue()!=null) {
myBean.setInputFieldValuePage2(ifld2.getValue().toString());
}
else {
myBean.setInputFieldValuePage2("NULL VALUE");
}
myBean.setMethod("doProcessAfterInput");
}
public void doProcessBeforeOutput() throws PageException {
this.setJspName("masterPage.jsp");
}
public void onClickRadio(Event event) {
initBean();
myBean.setEvent("onClickRadio");
}
public void onCmdAvanti(Event event) {
initBean();
myBean.setEvent("onCmdAvanti");
}
}
}
//MyBean.java
package include.test.bean;
import java.io.Serializable;
public class MyBean implements Serializable {
private String event = "";
private String inputFieldValue = "";
private String inputFieldValuePage2 = "";
private String radioButtonValue= "";
private String method = "";
public String getEvent() {
return event;
}
public void setEvent(String e) {
event = e;
}
/**
* @return
*/
public String getInputFieldValue() {
return inputFieldValue;
}
/**
* @param string
*/
public void setInputFieldValue(String string) {
inputFieldValue = string;
}
/**
* @return
*/
public String getRadioButtonValue() {
return radioButtonValue;
}
/**
* @param string
*/
public void setRadioButtonValue(String string) {
radioButtonValue = string;
}
/**
* @return
*/
public String getInputFieldValuePage2() {
return inputFieldValuePage2;
}
/**
* @param string
*/
public void setInputFieldValuePage2(String string) {
inputFieldValuePage2 = string;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return "MyBean [method=" + method + ", event="
+ event + ", inputFieldValue=" + inputFieldValue
+ ", inputFieldValuePage2=" + inputFieldValuePage2
+ ", radioButtonValue=" + radioButtonValue + "]";
}
/**
* @return
*/
public String getMethod() {
return method;
}
/**
* @param string
*/
public void setMethod(String string) {
method = string;
}
}
//普里莫·卡索:
//编译异常:
//•没有可用的渲染器上下文(没有RenderContext属性的htmlb标记必须嵌套在RenderContext标记中)
//masterPage.jsp
包括第1页开始
包括第1页结束
包括第2页开始
包括第2页结束
包括第3页开始
包括第3页结束
//includedPage1.jsp
//includedPage2.jsp
警报(“ID CAMPO:+)
//includedPage3.jsp
警报(“ID脉冲:+)
//第二卡索:
//例外情况:
//•内苏纳
//成分:
//•Solo I campi APPLATENTI al form da cui PARE l'evento vengono inviati al server,la causaèla creazione di piùform e e quindi di conseguenza nell'HTTP请求trovo Solo I campi del form da cuièstaqto EFFETTUTUATO il提交(evento)
//masterPage.jsp
包括第1页开始
包括第1页结束
包括第2页开始
包括第2页结束
包括第3页开始
包括第3页结束
//includedPage1.jsp
includedPage2.jsp
警报(“ID CAMPO:+)
//includedPage3.jsp
警报(“ID脉冲:+)
警报(“ID脉冲:+)
//附录:
//MasterPage.java
包装包括测试;
导入include.test.bean.MyBean;
导入com.sapportals.htmlb.*;
导入com.sapportals.htmlb.enum.*;
导入com.sapportals.htmlb.event.*;
导入com.sapportals.htmlb.page.*;
导入com.saportals.portal.htmlb.page.*;
导入com.sapportals.portal.prt.component.*;
公共类母版页扩展了PageProcessorComponent{
公共数据页getPage(){
返回新的MasterPageDynPage();
}
公共静态类MasterPageDynPage扩展了JSPDynPage{
私有MyBean MyBean=null;
私有void initBean(){
IPortalComponentSession组件会话组件会话=
((IPortalComponentRequest)getRequest()).getComponentSession();
对象o=componentSession.getValue(“myBean”);
if(o==null | |!(MyBean的o实例)){
myBean=新的myBean();
putValue(“myBean”,myBean);
}否则{
myBean=(myBean)o;
}
}
公共空间初始化(){
IPortalComponentSession组件会话组件会话=
((IPortalComponentRequest)getRequest()).getComponentSession();
对象o=componentSession.getValue(“myBean”);
if(o==null | |!(MyBean的o实例)){
myBean=新的myBean();
putValue(“myBean”,myBean);
}否则{
myBean=(myBean)o;
}
setMethod(“doInitialization”);
}
public void doProcessAfterInput()引发页面异常{
initBean();
InputField ifld=(InputField)getComponentByName(“fldInputField”);
如果(ifld!=null&&ifld.getValue()!=null){
myBean.setInputFieldValue(ifld.getValue().toString());
}
否则{
setInputFieldValue(“空值”);
}
RadioButtonGroup RadioButtonGroup=(RadioButtonGroup)getComponentByName(“flduterRegistrato”);
if(radioButtonGroup!=null&&radioButtonGroup.getSelection()!=null){
设置RadioButtonValue(radioButtonGroup.getSelection());
}
否则{
myBean.setRadioButtonValue(“NULL”);
}
InputField ifld2=(InputField)getComponentByName(“fldInputFieldPage2”);
如果(ifld2!=null&&ifld2.getValue()!=null){
myBean.setInputFieldValuePage2(ifld2.getValue().toString());
}
否则{
setInputFieldValuePage2(“空值”);
}
setMethod(“doProcessAfterInput”);
}
public void doProcessBeforeOutput()引发页面异常{
setJspName(“masterPage.jsp”);
}
公共广播电台(活动){
initBean();
setEvent(“onClickRadio”);
}
onCmdAvanti(事件)的公共无效{
initBean();
setEvent(“onCmdAvanti”);
}
}
}
//MyBean.java
包include.test.bean;
导入java.io.Serializable;
公共类MyBean实现了可序列化{
私有字符串事件=”;
私有字符串inputFieldValue=“”;
私有字符串inputFieldValuePage2=“”;
私有字符串radioButtonValue=“”;
私有字符串方法=”;
公共字符串getEvent(){
返回事件;
}
公共void setEvent(字符串e){
事件=e;
}
/**
*@返回
*/
公共字符串getInputFieldValue(){
返回inputFieldValue;
}
/**
*@param字符串
*/
公共无效setInputFieldValu