You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Grant Smith (JIRA)" <de...@myfaces.apache.org> on 2006/09/27 20:17:59 UTC
[jira] Reopened: (TOMAHAWK-450) inputHtml component without a form
produces NotNullException - it is able to warn
[ http://issues.apache.org/jira/browse/TOMAHAWK-450?page=all ]
Grant Smith reopened TOMAHAWK-450:
----------------------------------
> inputHtml component without a form produces NotNullException - it is able to warn
> ---------------------------------------------------------------------------------
>
> Key: TOMAHAWK-450
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-450
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Html Editor
> Affects Versions: 1.1.3-SNAPSHOT
> Environment: Doesn't matter
> Reporter: Ondrej Svetlik
> Assigned To: Grant Smith
> Attachments: InputHtmlRenderer.java.diff
>
>
> Try to use <t:inputHtml /> outside a form, you'll get this:
> java.lang.NullPointerException
> at org.apache.myfaces.custom.inputHtml.InputHtmlRenderer.encodeEndNormalMode(InputHtmlRenderer.java:235)
> at org.apache.myfaces.custom.inputHtml.InputHtmlRenderer.encodeEnd(InputHtmlRenderer.java:87)
> at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
> ... and so on
> File affected is:
> http://svn.apache.org/repos/asf/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
> The code is:
> private void encodeEndNormalMode(FacesContext context, InputHtml editor) throws IOException {
> String clientId = editor.getClientId(context);
> String formId;
> {
> UIComponent tmpComponent = editor.getParent();
> while(!(tmpComponent instanceof UIForm) ){
> tmpComponent = tmpComponent.getParent();
> }
> formId = tmpComponent.getClientId(context);
> }
> This is a simple fix that would have spared me a few nightmarish hours:
> private void encodeEndNormalMode(FacesContext context, InputHtml editor) throws IOException {
> String clientId = editor.getClientId(context);
> String formId;
> {
> UIComponent tmpComponent = editor.getParent();
> while((tmpComponent != null) && !(tmpComponent instanceof UIForm) ){
> tmpComponent = tmpComponent.getParent();
> }
> if (tmpComponent == null) {
> log.warn("The inputHtml component must be within a form, giving up!");
> return;
> }
> formId = tmpComponent.getClientId(context);
> }
> Or if you like svn diff better:
> --- InputHtmlRenderer.java (revision 409862)
> +++ InputHtmlRenderer.java (working copy)
> @@ -231,9 +231,13 @@
> String formId;
> {
> UIComponent tmpComponent = editor.getParent();
> - while(!(tmpComponent instanceof UIForm) ){
> + while((tmpComponent != null) && !(tmpComponent instanceof UIForm) ){
> tmpComponent = tmpComponent.getParent();
> }
> + if (tmpComponent == null) {
> + log.warn("The inputHtml component must be within a form, giving up!");+ return;
> + }
> formId = tmpComponent.getClientId(context);
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira