JSF命令按钮未调用bean方法
我的jsf命令按钮没有调用它应该调用的方法。代码如下:JSF命令按钮未调用bean方法,jsf,file-upload,primefaces,Jsf,File Upload,Primefaces,我的jsf命令按钮没有调用它应该调用的方法。代码如下: <h:form> <h:outputText value="Data de nascimento" style="font-size: 15px; float:left;margin-left:20%;" /> <br /> <h:inputText value="#{registroP
<h:form>
<h:outputText value="Data de nascimento"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<h:inputText value="#{registroPageMBean.usuario.nascimento}"
styleClass="default_input"
style="float:left;margin-left:20%;width:60%"></h:inputText>
<h:outputText value="Foto de Perfil"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<p:fileUpload value="#{registroPageMBean.file}" mode="simple"
skinSimple="true" label="Enviar arquivo" />
<br />
<br />
<br />
<h:commandButton rendered="true" styleClass="default_button" value="Finalizar"
action="#{registroPageMBean.registrar}" />
</h:form>
我在另一个XHTML页面中编写了类似的代码,它成功了。因此,我将该命令按钮放在另一页中,它给了我一个我以前从未见过的NullPointerException
谢谢大家! 您确定上载的文件不为空吗?尝试在register()方法中运行调试
如果这不是问题所在,请发布堆栈跟踪。“一个堆栈跟踪值千言万语”。这是它工作的另一个XHTML
<h:body
style="background-color: #2b5dad;width:100%;height:100%;margin:0px;">
<div class="lay_page">
<div style="width: 100%; height: 100%; padding-top: 3.5%;">
<h:outputText styleClass="title_font" value="PROTÓTIPO ALPHA" />
</div>
</div>
<div class="lay_page_center">
<div class="lay_page_center_center">
<h3 class="default_font">Login</h3>
<h:form>
<h:outputText value="Email"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<h:inputText value="#{loginPageMBean.email}"
styleClass="default_input"
style="float:left;margin-left:20%;width:60%"></h:inputText>
<br />
<h:outputText value="Senha"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<h:inputSecret value="#{loginPageMBean.senha}"
styleClass="default_input"
style="float:left;margin-left:20%;width:60%" />
<br />
<br />
<br />
<h:commandButton styleClass="default_button" value="Login"
action="#{loginPageMBean.login}"></h:commandButton>
<h:commandButton styleClass="default_button" value="Registrar"
action="register_page.xhtml"></h:commandButton>
<h:commandButton styleClass="default_button" value="Próximo passo"
action="#{registroPageMBean.registrar}"></h:commandButton>
</h:form>
</div>
</div>
<div class="lay_page"></div>
登录
这次我尝试使用另一个XHTML,它成功了。为什么这只能在一个xhtml中工作?这个文件使用同一个bean?您在这个xhtml中没有足够的权限。
<h:body
style="background-color: #2b5dad;width:100%;height:100%;margin:0px;">
<div class="lay_page">
<div style="width: 100%; height: 100%; padding-top: 3.5%;">
<h:outputText styleClass="title_font" value="PROTÓTIPO ALPHA" />
</div>
</div>
<div class="lay_page_center">
<div class="lay_page_center_center">
<h3 class="default_font">Login</h3>
<h:form>
<h:outputText value="Email"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<h:inputText value="#{loginPageMBean.email}"
styleClass="default_input"
style="float:left;margin-left:20%;width:60%"></h:inputText>
<br />
<h:outputText value="Senha"
style="font-size: 15px; float:left;margin-left:20%;" />
<br />
<h:inputSecret value="#{loginPageMBean.senha}"
styleClass="default_input"
style="float:left;margin-left:20%;width:60%" />
<br />
<br />
<br />
<h:commandButton styleClass="default_button" value="Login"
action="#{loginPageMBean.login}"></h:commandButton>
<h:commandButton styleClass="default_button" value="Registrar"
action="register_page.xhtml"></h:commandButton>
<h:commandButton styleClass="default_button" value="Próximo passo"
action="#{registroPageMBean.registrar}"></h:commandButton>
</h:form>
</div>
</div>
<div class="lay_page"></div>