我正在努力将应用程序从Websphere迁移到tomcat,这在很大程度上已经取得了成功。先前的应用程序在Java EE 5上运行,我将其更新为Java7。在此过程中,我将JSTL更新为1.2,将myfaces更新为2.0,以及其他一些东西。这是我当前的罐子库:
除了h:commandlink以外,该应用程序的所有工作均正常。我相信这与更新jar和Java版本有关。我可以访问所有其他页面,只是导航按钮不起作用。这是他们的jsp:
<%-- tpl:metadata --%>
<%-- jsf:pagecode language="java" location="/src/pagecode/menu/Main.java" --%><%-- /jsf:pagecode --%>
<%-- /tpl:metadata --%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<link rel="stylesheet" type="text/css" media="screen"
href="../theme/menu.css">
<link rel="stylesheet" type="text/css" href="../theme/stylesheet.css"
title="Style">
<hx:viewFragment id="viewFragmentMain"><hx:scriptCollector id="scriptCollector1">
<% String Page = (session.getAttribute("mainPage") == null) ? "1" : (String)session.getAttribute("mainPage"); %>
<h:form id="formMenu" styleClass="form">
<ul id="tabmenu">
<li<%= (Page.compareTo("1") == 0) ? " class=active" : ""%>><h:commandLink id="link1" action="#{pc_Main.doLink1Action}"><h:outputText id="textMenu1" styleClass="outputText" value="Page 1"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("2") == 0) ? " class=active" : ""%>><h:commandLink id="link2" action="#{pc_Main.doLink2Action}"><h:outputText id="textMenu2" styleClass="outputText" value="Page 2"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("3") == 0) ? " class=active" : ""%>><h:commandLink id="link3" action="#{pc_Main.doLink3Action}"><h:outputText id="textMenu3" styleClass="outputText" value="Page 3"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("5") == 0) ? " class=active" : ""%>><h:commandLink id="link5" action="#{pc_Main.doLink5Action}"><h:outputText id="textMenu5" styleClass="outputText" value="Page 5"></h:outputText></h:commandLink></li>
<% if (request.isUserInRole("giftAdmin") | request.isUserInRole("giftAdminBackup") | request.isUserInRole("merchAdmin") | request.isUserInRole("merchAdminBackup")){ %>
<li <%= (Page.compareTo("4") == 0) ? " class=active" : ""%>><h:commandLink
id="link4" action="#{pc_Main.doLink4Action}">
<h:outputText id="textMenu4" styleClass="outputText"
value="Page 4"></h:outputText>
</h:commandLink></li>
<li><a href="<%= request.getContextPath() %>/forms/Help.pdf" target="_blank">Help</a></li>
<% } %>
</ul>
</h:form>
</hx:scriptCollector>
单击链接时,假设要调用此类中相应的方法。但是,它实际上从未进入此类。假定在索引中进行调用,然后根据导航规则返回正确的视图,但从未将其变为正确的方法。
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpSession;
import com.accounting.credit.ControlBean;
import com.accounting.credit.CreditAction;
import com.accounting.credit.CreditRequest;
import jxl.common.Logger;
import pagecode.PageCodeBase;
public class Main extends PageCodeBase {
private final static Logger LOG = Logger.getLogger(Main.class);
protected HtmlCommandLink link2;
protected HtmlOutputText textMenu1;
protected HtmlForm formMenu;
protected HtmlCommandLink link3;
protected HtmlCommandLink link4;
protected HtmlCommandLink link1;
protected HtmlOutputText textMenu2;
protected HtmlOutputText textMenu3;
protected HtmlOutputText textMenu4;
protected CreditAction action;
protected CreditRequest req;
protected ControlBean control;
protected HtmlOutputText textMenu5;
protected HtmlCommandLink link5;
protected HtmlCommandLink getLink2() {
if (link2 == null) {
link2 = (HtmlCommandLink) findComponentInRoot("link2");
}
return link2;
}
protected HtmlOutputText getTextMenu1() {
if (textMenu1 == null) {
textMenu1 = (HtmlOutputText) findComponentInRoot("textMenu1");
}
return textMenu1;
}
protected HtmlForm getFormMenu() {
if (formMenu == null) {
formMenu = (HtmlForm) findComponentInRoot("formMenu");
}
return formMenu;
}
protected HtmlCommandLink getLink3() {
if (link3 == null) {
link3 = (HtmlCommandLink) findComponentInRoot("link3");
}
return link3;
}
protected HtmlCommandLink getLink4() {
if (link4 == null) {
link4 = (HtmlCommandLink) findComponentInRoot("link4");
}
return link4;
}
protected HtmlCommandLink getLink1() {
if (link1 == null) {
link1 = (HtmlCommandLink) findComponentInRoot("link1");
}
return link1;
}
public String doLink1Action() {
// Type Java code that runs when the component is clicked
LOG.info("In doLink1Action");
HttpSession session = (HttpSession)getFacesContext().getExternalContext().getSession(true);
session.setAttribute("edit", "False");
getReq().clear();
getAction().clear();
return "page1";
}
public String doLink2Action() {
// Type Java code that runs when the component is clicked
LOG.info("In doLink2Action");
HttpSession session = (HttpSession)getFacesContext().getExternalContext().getSession(true);
session.setAttribute("edit", "False");
getReq().clear();
getAction().clear();
return "page2";
}
public String doLink3Action() {
// Type Java code that runs when the component is clicked
LOG.info("In doLink3Action");
HttpSession session = (HttpSession)getFacesContext().getExternalContext().getSession(true);
session.setAttribute("edit", "False");
getReq().clear();
getAction().clear();
return "pag3";
}
public String doLink4Action() {
// Type Java code that runs when the component is clicked
LOG.info("In doLink4Action");
HttpSession session = (HttpSession)getFacesContext().getExternalContext().getSession(true);
session.setAttribute("edit", "False");
getReq().clear();
getAction().clear();
return "page4";
}
protected HtmlOutputText getTextMenu2() {
if (textMenu2 == null) {
textMenu2 = (HtmlOutputText) findComponentInRoot("textMenu2");
}
return textMenu2;
}
protected HtmlOutputText getTextMenu3() {
if (textMenu3 == null) {
textMenu3 = (HtmlOutputText) findComponentInRoot("textMenu3");
}
return textMenu3;
}
protected HtmlOutputText getTextMenu4() {
if (textMenu4 == null) {
textMenu4 = (HtmlOutputText) findComponentInRoot("textMenu4");
}
return textMenu4;
}
/**
* @managed-bean true
*/
protected CreditAction getAction() {
if (action == null) {
action = (CreditAction) getFacesContext().getApplication()
.createValueBinding("#{action}")
.getValue(getFacesContext());
}
return action;
}
/**
* @managed-bean true
*/
protected void setAction(CreditAction action) {
this.action = action;
}
/**
* @managed-bean true
*/
protected CreditRequest getReq() {
if (req == null) {
req = (CreditRequest) getFacesContext().getApplication()
.createValueBinding("#{req}").getValue(getFacesContext());
}
return req;
}
/**
* @managed-bean true
*/
protected void setReq(CreditRequest req) {
this.req = req;
}
/**
* @managed-bean true
*/
protected ControlBean getControl() {
if (control == null) {
control = (ControlBean) getFacesContext().getApplication()
.createValueBinding("#{control}").getValue(
getFacesContext());
}
return control;
}
/**
* @managed-bean true
*/
protected void setControl(ControlBean control) {
this.control = control;
}
protected HtmlOutputText getTextMenu5() {
if (textMenu5 == null) {
textMenu5 = (HtmlOutputText) findComponentInRoot("textMenu5");
}
return textMenu5;
}
protected HtmlCommandLink getLink5() {
if (link5 == null) {
link5 = (HtmlCommandLink) findComponentInRoot("link5");
}
return link5;
}
public String doLink5Action() {
// Type Java code that runs when the component is clicked
return "page5";
}
}
onclick与以前的版本不同,这使我相信它与版本有关,但是我还没有发现与onclick为何会改变有关的任何内容。
先前的onclick是:
<a id="viewFragmentMain:formMenu:link2" href="#" onclick="document.forms['viewFragmentMain:formMenu']['__LINK_TARGET__'].disabled=false;document.forms['viewFragmentMain:formMenu']['__LINK_TARGET__'].value='viewFragmentMain:formMenu:link2'; document.forms['viewFragmentMain:formMenu'].submit();document.forms['viewFragmentMain:formMenu']['__LINK_TARGET__'].disabled=true; return false;"><span id="viewFragmentMain:formMenu:textMenu2" class="outputText">My Requests</span></a>
新按钮的onclick是:
<a href="#" onclick="return myfaces.oam.submitForm('viewFragmentMain:formMenu','viewFragmentMain:formMenu:link2');" id="viewFragmentMain:formMenu:link2"><span id="viewFragmentMain:formMenu:textMenu2" class="outputText">My Requests</span></a>
简而言之,我想问的是如何使新链接看起来像带有更新版本的旧链接?
答案 0 :(得分:0)
什么版本的WebSphere? 通常,除非明确声明要覆盖WAS中捆绑的JSF实施jar,否则通常不要将其捆绑在应用中。如果是这样,请检查文档here
答案 1 :(得分:0)
我发现该问题与使用仍在“使用中”的旧Websphere jar有关。我上面有使用前缀hx的IBM face的标签库。这仅适用于Websphere服务器。因此,在删除它们的过程中,我不得不重做已实现的标签,这些标签大多数都具有简单的等效功能。在后端出现的另一个问题是我们为IBM Faces实现的,因此我目前正在重写过程中以合并实际使用的标签。我还必须更改仍设置为包含IMB上下文参数的web.xml,因此我将其删除。
正如您在此处看到的,我删除了hx标签库,该库允许链接正常工作,并且没有问题。我还必须从web.xml文件中删除所有提及IBM实例和源的信息。
<%-- tpl:metadata --%>
<%-- jsf:pagecode language="java" location="/src/pagecode/menu/Main.java" --%><%-- /jsf:pagecode --%>
<%-- /tpl:metadata --%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<link rel="stylesheet" type="text/css" media="screen" href="theme/menu.css">
<link rel="stylesheet" type="text/css" href="theme/stylesheet.css" title="Style">
<% String Page = (session.getAttribute("mainPage") == null) ? "1" : (String)session.getAttribute("mainPage"); %>
<h:form id="formMenu" styleClass="form">
<ul id="tabmenu">
<li<%= (Page.compareTo("1") == 0) ? " class=active" : ""%>><h:commandLink id="link1" action="#{pc_Main.doLink1Action}"><h:outputText id="textMenu1" styleClass="outputText" value="Credit/Gift Card Request"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("2") == 0) ? " class=active" : ""%>><h:commandLink id="link2" action="#{pc_Main.doLink2Action}"><h:outputText id="textMenu2" styleClass="outputText" value="My Requests"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("3") == 0) ? " class=active" : ""%>><h:commandLink id="link3" action="#{pc_Main.doLink3Action}"><h:outputText id="textMenu3" styleClass="outputText" value="My ToDo's"></h:outputText></h:commandLink></li>
<li<%= (Page.compareTo("5") == 0) ? " class=active" : ""%>><h:commandLink id="link5" action="#{pc_Main.doLink5Action}"><h:outputText id="textMenu5" styleClass="outputText" value="Search"></h:outputText></h:commandLink></li>
<% if (request.isUserInRole("giftAdmin") | request.isUserInRole("giftAdminBackup") | request.isUserInRole("merchAdmin") | request.isUserInRole("merchAdminBackup")){ %>
<li <%= (Page.compareTo("4") == 0) ? " class=active" : ""%>><h:commandLink
id="link4" action="#{pc_Main.doLink4Action}">
<h:outputText id="textMenu4" styleClass="outputText"
value="Accounting"></h:outputText>
</h:commandLink></li>
<li><a href="<%= request.getContextPath() %>/forms/Help.pdf" target="_blank">Help</a></li>
<% } %>
</ul>
</h:form>