• 締切済み

JSFで、マネージビーンに画面の値が反映されない

MyFacesを使って開発をしています。画面からの入力値が、マネージドビーンへうまく値設定できません。JSP側とManagedBean側へ値を受け渡すための設定である、faces-config.xml、マネージドビーンの設定は何度見直してもあっています(コピー、ペーストで入力してます)。値が反映されない理由がわからないのですが、コンソール上に、次のエラーが出力されます。 宜しくお願いします。 ------------------------------------------------- 2006/04/23 14:35:51 org.apache.myfaces.renderkit.html.HtmlRendererUtils decodeUIInput 警告: There should always be a submitted value for an input if it is rendered, its form is submitted, and it is not disabled or read-only. 2006/04/23 14:35:51 org.apache.myfaces.renderkit.html.HtmlRendererUtils decodeUIInput 警告: There should always be a submitted value for an input if it is rendered, its form is submitted, and it is not disabled or read-only.

みんなの回答

回答No.3

コンソールに表示されたエラーメッセージは次の通りです。 2006/04/23 14:35:51 org.apache.myfaces.renderkit.html.HtmlRendererUtils decodeUIInput 警告: There should always be a submitted value for an input if it is rendered, its form is submitted, and it is not disabled or read-only. 2006/04/23 14:35:51 org.apache.myfaces.renderkit.html.HtmlRendererUtils decodeUIInput 警告: There should always be a submitted value for an input if it is rendered, its form is submitted, and it is not disabled or read-only. null null 2006/04/23 14:35:51 org.apache.catalina.core.StandardWrapperValve invoke 致命的: サーブレット Faces Servlet のServlet.service()が例外を投げました javax.faces.FacesException: Error calling action method of component with id _id1:_id8 at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74) at javax.faces.component.UICommand.broadcast(UICommand.java:106) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164) at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source) Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{registUserManagedBean.addUserInfoEvt} at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) ... 23 more Caused by: java.lang.NullPointerException at java.util.regex.Matcher.getTextLength(Unknown Source) at java.util.regex.Matcher.reset(Unknown Source) at java.util.regex.Matcher.<init>(Unknown Source) at java.util.regex.Pattern.matcher(Unknown Source) at managedBean.RegistUserManagedBean.addUserInfoEvt(RegistUserManagedBean.java:73) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129) ... 24 more

回答No.2

マネージドビーンは次の通りです。 public class RegistUserManagedBean implements Serializable{ private static final long serialVersionUID = -3090629182234182743L; //利用者ID private String userId; //利用者名 private String userName; //パスワード private String password; //利用者権限[選択値] private String userKbn; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUserKbn() { return userKbn; } public void setUserKbn(String userKbn) { this.userKbn = userKbn; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String addUserInfoEvt(){ System.out.println(password); System.out.println(userName); //パスワード[0-9,a-z,A-Z,-,_]のいずれか Pattern p = Pattern.compile("[0-9a-zA-Z|[-]|[_]]+"); Matcher m = p.matcher(password); if(!m.matches()) { Message.addErrMessage("userRegist_err03"); return "error"; } //パスワード[4桁-8桁で収まっているかのチェック] if((password.length() > 8) || (password.length() < 4)){ Message.addErrMessage("userRegist_err04"); return "error"; }

回答No.1

画面側のコード次のようになっています。 <html> <body> <f:view> <br> <br> <h:outputText>利用者名、パスワード、利用者区分を入力して下さい。</h:outputText> <h:form> <blockquote> <table cellpadding="2"> <tr> <td><h:outputText value="利用者名:" /></td> <td><h:inputText id="利用者名" required = "true" value="#{registUserManagedBean.userName}" maxlength="20" /></td> </tr> <tr> <td><h:outputText value="パスワード:" /></td> <td><h:inputText id="パスワードa" required = "true" value = "#{registUserManagedBean.password}" maxlength="8" /></td> </tr> <tr> <td><h:outputText>利用者区分:</h:outputText></td> <td> <h:selectOneMenu value="#{registUserManagedBean.userKbn}" > <f:selectItem itemValue="1" itemLabel="システム管理者" /> <f:selectItem itemValue="2" itemLabel="役員" /> </h:selectOneMenu> </td> </tr> </table> </blockquote> <h:commandButton action="#{registUserManagedBean.addUserInfoEvt}" value="登録" /> <br> <h:messages showDetail="true" showSummary="false" styleClass = "errorMessage" /> </h:form> <h:form> <br> <br> <h:commandButton action="#{registUserManagedBean.logoutEvt}" value="ログアウト" /> </h:form> </f:view> </body> </html>

関連するQ&A