当我开始使用@ViewScoped和f:metadata,f:viewParam来编辑数据表中的项目时,之前工作的代码停止工作。
我正在使用JSF-2.2和Prettyfaces-2.0.12.Final
以下是类似的问题,但没有答案:
com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
找到以下完整的堆栈跟踪:
com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/restricted/professional_details.xhtml]
java.lang.NullPointerException
at java.net.URLEncoder.encode(URLEncoder.java:205)
at com.sun.faces.context.UrlBuilder.addValuesToParameter(UrlBuilder.java:318)
at com.sun.faces.context.UrlBuilder.addParameters(UrlBuilder.java:127)
at com.sun.faces.context.ExternalContextImpl.encodeBookmarkableURL(ExternalContextImpl.java:1055)
at com.sun.faces.application.view.MultiViewHandler.getBookmarkableURL(MultiViewHandler.java:407)
at org.ocpsoft.rewrite.faces.RewriteViewHandler.getBookmarkableURL(RewriteViewHandler.java:164)
at com.sun.faces.renderkit.html_basic.OutcomeTargetRenderer.getEncodedTargetURL(OutcomeTargetRenderer.java:194)
at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.renderAsActive(OutcomeTargetLinkRenderer.java:158)
at com.sun.faces.renderkit.html_basic.OutcomeTargetLinkRenderer.encodeBegin(OutcomeTargetLinkRenderer.java:96)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:41)
at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:268)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.pe.application.PEFilter.doFilter(PEFilter.java:64)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:1
23)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
professional_details.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
xmlns:pf="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:outputStylesheet library="css" name="admin.css" />
<h:outputStylesheet library="css" name="font.css" />
<h:outputStylesheet library="css" name="font-awesome.css" />
<h:outputStylesheet library="css" name="jquery-ui.css" />
<h:outputScript library="js" name="jquery.min.js" target="head" />
<h:outputScript library="js" name="jquery-ui.min.js" target="head" />
<h:outputScript library="js" name="bootstrap.js" target="head" />
<h:outputScript library="js" name="bootstrap-modal.js" target="head" />
<h:outputScript library="js" name="script.js" target="head" />
<h:outputScript library="js" name="signup.js" target="head" />
<script type="text/javascript">
//For calendar
$(function() {
$(".datepicker").datepicker({
showOtherMonths : true,
selectOtherMonths : true,
showButtonPanel : true,
changeMonth : true,
changeYear : true,
yearRange : '1980:2014',
dateFormat : 'mm/dd/yy',
showWeek : true
});
});
</script>
<ui:include src="../includes/header.xhtml" />
<div class="container-fluid">
<f:metadata>
<f:viewParam name="id"
value="#{professionalDetailsManagedBean.professionalBean}"
converter="#{professionalConverter}"
converterMessage="Unknown professional please use a link from within the system."
required="true"
requiredMessage="Bad request, please use a link from within the system." />
</f:metadata>
<h:messages />
<!-- <h:form enctype="multipart/form-data"> -->
<h:form id="include">
<ui:include src="../includes/adminSideMenu.xhtml" />
</h:form>
<section class="row-fluid">
<div role="main" class="span10">
<div class="row-fluid">
<section role="main" class="span12"> <!-- <div class="span10"> -->
<h1>
#{professionalDetailsManagedBean.professionalBean.professionalName}</h1>
<br></br>
<h:form id="profTabs">
<ul class="nav nav-tabs" style="font-size: 15px;">
<li class="active"><h:link
outcome="pretty:professionalDetails" value="Profile">
<f:param name="professionalName"
value="#{professionalDetailsManagedBean.professionalBean.professionalName}" />
<f:param name="id"
value="#{professionalDetailsManagedBean.professionalBean.professionalId}" />
</h:link></li>
<li><h:link outcome="pretty:professionalInvestments"
value="Investments">
<f:param name="professionalName"
value="#{professionalDetailsManagedBean.professionalBean.professionalName}" />
<f:param name="professionalInvestements"
value="#{professionalDetailsManagedBean.professionalBean.professionalId}" />
</h:link></li>
<li><h:link outcome="pretty:professionalInvestedFunds"
value="Invested Funds">
<f:param name="professionalName"
value="#{professionalDetailsManagedBean.professionalBean.professionalName}" />
<f:param name="professionalInvestedFunds"
value="#{professionalDetailsManagedBean.professionalBean.professionalId}" />
</h:link></li>
</ul>
</h:form> <h:form id="profData" enctype="multipart/form-data">
<div class="row-fluid">
<div class="span10"></div>
<div class="span2 pull-right">
<h:graphicImage
value="/image?id=#{professionalDetailsManagedBean.professionalBean.professionalId}%26type=Professional" />
</div>
</div>
<div class="row-fluid">
<div class="span9">
<div class="span6">
<div class="control-group">
<h6>Name</h6>
<div class="controls">
<h:messages showDetail="false" showSummary="true" />
<h:inputText id="inputName"
value="#{professionalDetailsManagedBean.professionalBean.professionalName}"
required="true">
<f:ajax listener="#{professionalManagedBean.duplicateCheck}"
render="error" />
<f:passThroughAttribute name="placeholder"
value="Please provide Name..." />
<f:passThroughAttribute name="required" value="true" />
</h:inputText>
<h:outputText id="error"
value="#{professionalManagedBean.result}"
style="margin-left: 0px; color: red;" />
<div class="error" style="margin-left: 0px; color: red;"
id="inputNameError" />
</div>
</div>
<div class="control-group">
<h6>Designation</h6>
<div class="controls">
<h:inputText id="designation"
value="#{professionalDetailsManagedBean.professionalBean.designation}">
</h:inputText>
<div class="error" style="margin-left: 0px; color: red;"
id="designationError" />
</div>
</div>
<div class="control-group">
<h6>Firm Name</h6>
<div class="controls">
<pf:autoComplete
value="#{autoCompleteManagedBean.testFieldBean}"
p:placeholder="Firm Name"
completeMethod="#{autoCompleteManagedBean.firmsCompaniesAutoComplete}"
var="p" itemLabel="#{p.name}" minQueryLength="3"
style="position: inherit;" id="suggestionBoxFirmName">
</pf:autoComplete>
</div>
</div>
<div class="control-group">
<h6>Email ID</h6>
<div class="controls">
<h:inputText id="emailId"
value="#{professionalDetailsManagedBean.professionalBean.emailId}">
</h:inputText>
<div class="error" style="margin-left: 0px; color: red;"
id="emailError"></div>
</div>
</div>
<div class="control-group">
<h6>Phone Number</h6>
<div class="controls">
<h:inputText type="text" id="phoneNumber"
p:placeholder="+001 5689996544" name="email"
value="#{professionalDetailsManagedBean.professionalBean.phone}">
</h:inputText>
<div class="error" style="margin-left: 0px; color: red;"
id="phoneError"></div>
</div>
</div>
</div>
<div class="span6">
<div class="control-group">
<h6>Join Date</h6>
<div class="controls">
<h:inputText type="text" styleClass="datepicker"
value="#{professionalDetailsManagedBean.professionalBean.joinDate}"
id="inputJoined" readonly="#{facesContext.renderResponse}">
</h:inputText>
<div class="error" style="margin-left: 0px; color: red;"
id="inputJoinedError"></div>
</div>
</div>
<div class="control-group">
<h6>Exit Date</h6>
<div class="controls">
<h:inputText type="text" styleClass="datepicker"
value="#{professionalDetailsManagedBean.professionalBean.exitDate}"
id="inputLeaved" readonly="#{facesContext.renderResponse}">
</h:inputText>
<div class="error" style="margin-left: 0px; color: red;"
id="inputLeavedError"></div>
</div>
</div>
<div class="control-group">
<h6>Rank</h6>
<div class="controls">
<h:selectOneMenu
value="#{professionalDetailsManagedBean.professionalBean.rank}">
<f:selectItem itemLabel="0" itemValue="0" />
<f:selectItem itemLabel="1" itemValue="1" />
<f:selectItem itemLabel="2" itemValue="2" />
<f:selectItem itemLabel="3" itemValue="3" />
</h:selectOneMenu>
</div>
</div>
<div class="control-group">
<h6>Office</h6>
<div class="controls">
<h:selectOneMenu
value="#{professionalDetailsManagedBean.professionalBean.office}">
<f:selectItem itemLabel="0" itemValue="0" />
<f:selectItem itemLabel="1" itemValue="1" />
<f:selectItem itemLabel="2" itemValue="2" />
<f:selectItem itemLabel="3" itemValue="3" />
</h:selectOneMenu>
</div>
</div>
<div class="control-group">
<h6>Function</h6>
<div class="controls">
<h:selectOneMenu
value="#{professionalDetailsManagedBean.professionalBean.function}">
<f:selectItem itemLabel="Please Select"
noSelectionOption="true" />
<f:selectItem itemLabel="Investment" itemValue="Investment" />
<f:selectItem itemLabel="Administrative"
itemValue="Administrative" />
<f:selectItem itemLabel="Operations" itemValue="Operations" />
</h:selectOneMenu>
</div>
</div>
</div>
</div>
<div class="span3" style="margin-top: 187px;">
<div>
<div class="control-group">
<div class="center">
<!-- <h:graphicImage
value="/image?id=#{professionalDetailsManagedBean.professionalBean.professionalId}%26type=Professional" /> -->
</div>
<div class="controls">
<h:inputFile id="file" name="file"
value="#{professionalDetailsManagedBean.professionalBean.part}"
required="true" requiredMessage="File not selected"
label="file" />
<h:commandButton value="Upload"
action="#{professionalDetailsManagedBean.uploadProfessionalImage(professionalManagedBean.professionalBean.professionalId)}" />
</div>
</div>
</div>
<div class="well" style="text-align: center">
<h:commandButton styleClass="btn btn-primary btn-large"
value="Save Changes"
action="#{professionalDetailsManagedBean.updateProfessionalDetails(professionalManagedBean.professionalBean)}"></h:commandButton>
<h:outputText value=" "></h:outputText>
<a href="#" class="btn btn-large">Cancel</a>
</div>
<h6>Is LP (Limited Partner)?</h6>
<label class="checkbox"> <h:selectBooleanCheckbox
name="is_active"
value="#{professionalDetailsManagedBean.professionalBean.isLp}" />
Yes
</label>
</div>
</div>
<div class="row-fluid">
<div class="span9" style="margin-left: 0px">
<div class="control-group">
<h6>Bio</h6>
<div class="controls">
<h:inputTextarea class="span13" name="biography" rows="6"
id="bio">
</h:inputTextarea>
<div class="error" style="margin-left: 0px; color: red;"
id="bioError"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h3 class="heading">Working Experience</h3>
<h4>Current :</h4>
<ul>
<ui:repeat var="experience"
value="#{professionalDetailsManagedBean.professionalBean.professionalWorkExpMap.entrySet().toArray()}">
<h:panelGroup rendered="#{experience.value.workStatus}">
<li><h:commandLink styleClass="topopup3">#{experience.value.firmOrPortfolioName}
<!-- <f:ajax
listener="#{professionalManagedBean.editProfessionalWorkExperience(experience.value.experienceId, experience.value.professionalId)}" /> -->
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-primary">
<span class="icon-pencil"></span>
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-warning">
<span class="icon-close"></span>
</h:commandLink></li>
<br></br>
</h:panelGroup>
</ui:repeat>
</ul>
<h4>Past :</h4>
<ul>
<ui:repeat var="experience"
value="#{professionalDetailsManagedBean.professionalBean.professionalWorkExpMap.entrySet().toArray()}">
<h:panelGroup rendered="#{!experience.value.workStatus}">
<li><h:commandLink styleClass="topopup3">#{experience.value.firmOrPortfolioName}
<!-- <f:ajax
listener="#{professionalManagedBean.editProfessionalWorkExperience(experience.value.experienceId, experience.value.professionalId)}" /> -->
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-primary">
<span class="icon-pencil"></span>
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-warning">
<span class="icon-close"></span>
</h:commandLink></li>
</h:panelGroup>
</ui:repeat>
</ul>
<div>
<a href="#" id="addworkexp"
class="btn btn-success pull-left topopup"><i
class="icon-plus"></i> Add Work Experience</a>
</div>
</div>
<div class="span4">
<h3 class="heading">Sectorall Focusus</h3>
<h:selectManyListbox
value="#{professionalDetailsManagedBean.professionalBean.sectorallFocusus}"
size="8" styleClass="defaultText">
<f:selectItems
value="#{newFieldsManagedBean.newFieldsBean.sectorMap.entrySet()}"
var="entry" itemValue="#{entry.value}"
itemLabel="#{entry.value}" />
</h:selectManyListbox>
</div>
<div class="span4">
<h3 class="heading">Qualifications</h3>
<ol>
<ui:repeat var="qualification"
value="#{professionalDetailsManagedBean.professionalBean.professionalQualificationMap.entrySet().toArray()}">
<li><h:commandLink styleClass="topopup_mini"
value="#{qualification.value.universityName}, #{qualification.value.degree}, #{qualification.value.stream}">
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-primary">
<span class="icon-pencil"></span>
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-warning">
<span class="icon-close"></span>
</h:commandLink></li>
</ui:repeat>
</ol>
<div>
<a href="#" id="addEduQuals"
class="btn btn-success pull-left topopup1"><i
class="icon-plus"></i> Add Education Qualification</a>
</div>
</div>
</div>
</div>
<div class="span3">
<h3 class="heading">Board Seats</h3>
<h4>Current :</h4>
<ul>
<ui:repeat var="board"
value="#{professionalDetailsManagedBean.professionalBean.boardSeatsMap.entrySet().toArray()}">
<h:panelGroup rendered="#{board.value.status}">
<li><h:commandLink styleClass="topopup4">#{board.value.firmOrPortfolioName}
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-primary">
<span class="icon-pencil"></span>
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-warning">
<span class="icon-close"></span>
</h:commandLink></li>
</h:panelGroup>
</ui:repeat>
</ul>
<h4>Past :</h4>
<ul>
<ui:repeat var="board"
value="#{professionalDetailsManagedBean.professionalBean.boardSeatsMap.entrySet().toArray()}">
<h:panelGroup rendered="#{!board.value.status}">
<li><h:commandLink styleClass="topopup4">#{board.value.firmOrPortfolioName}
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-primary">
<span class="icon-pencil"></span>
</h:commandLink> <h:commandLink styleClass="btn btn-mini btn-warning">
<span class="icon-close"></span>
</h:commandLink></li>
</h:panelGroup>
</ui:repeat>
</ul>
<div>
<a href="#" id="addbordseats"
class="btn btn-success pull-left topopup2"><i
class="icon-plus"></i> Add Board Seats</a>
</div>
</div>
</div>
</h:form>
</section>
</div>
</div>
</section>
<!-- </h:form> -->
</div>
</h:body>
</html>
ProfessionalDetailsManagedBean.Java:
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.apache.log4j.Logger;
@ManagedBean
@ViewScoped
public class ProfessionalDetailsManagedBean extends PaginationManagedBean
implements Serializable {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger
.getLogger(ProfessionalDetailsManagedBean.class);
private static final int DEFAULT_PAGE_INDEX = 1;
public ProfessionalBean professionalBean;
public ProfessionalDetailsManagedBean() {
super(DEFAULT_RECORDS_NUMBER, DEFAULT_PAGE_INDEX);
}
/**
* @return the professionalBean
*/
public ProfessionalBean getProfessionalBean() {
return professionalBean;
}
/**
* @param professionalBean
* the professionalBean to set
*/
public void setProfessionalBean(ProfessionalBean professionalBean) {
this.professionalBean = professionalBean;
}
public String updateProfessionalDetails() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Updating professional details: joinDate"
+ this.professionalBean.getJoinDate() + ", exitDate: "
+ this.professionalBean.getExitDate());
}
// Now updating the professional details in the db
IProfessionalOperations professionalOperations = new ProfessionalOperationsImpl();
professionalOperations
.updatePortfolioProfessional(this.professionalBean);
return null;
}
}
答案 0 :(得分:0)
在h:form中删除enctype后,代码正在运行。另外,删除了负责文件上传的标签。将所有文件上传标签移动到不同的h:form。
这只是一种解决方法,需要了解我们如何使其与mime内容一起使用。