myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: java.lang.IllegalArgumentException: Value is no String
Date Thu, 31 May 2007 15:03:33 GMT
Yes, I extended the myfaces class to fix the bug:

public class HtmlSelectOneRadio
  extends org.apache.myfaces.component.html.ext.HtmlSelectOneRadio
{
  /**
   * @see javax.faces.component.UIInput#setSubmittedValue(java.lang.Object)
   */
  @Override
  public void setSubmittedValue(Object submittedValue)
  {
    if (submittedValue == RendererUtils.NOTHING ||
      submittedValue ==
org.apache.myfaces.shared_impl.renderkit.RendererUtils.NOTHING)
      submittedValue = null;
    super.setSubmittedValue(submittedValue);
  }
}

On 5/30/07, Celso Nishioka <celso.nishioka@gmail.com> wrote:
> Andrew, I'm having the same issue.
>
> Did you get it solved?
>
> Thanks.
>
>
> On 11/29/06, Andrew Robinson < andrew.rw.robinson@gmail.com> wrote:
> > No that hasn't changed, I just checked the source. If you look at the
> > stack trace, somehow the value is an instance of
> >
> "org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils$1"
> -- it
> > is not null inside the
> "RendererUtils.getConvertedStringValue" method.
> >
> > How in the world that happened is beyond me.
> >
> > -Andrew
> >
> > On 11/29/06, Jeff Bischoff <jbischoff@klkurz.com> wrote:
> > > Andrew,
> > >
> > > Looking at the current code, it shouldn't throw that against a null
> > > value. Maybe they've changed this since your version? Perhaps you could
> > > try with the nightlies just to see if the same behavior happens?
> > >
> > > RenderUtils
> > > ------------
> > > public static String
> getConvertedStringValue(FacesContext context,
> > >
> UIComponent component,
> > > Converter converter, Object value) {
> > >          if (converter == null) {
> > >              if (value == null) {
> > >                  return "";
> > >              }
> > >              else if (value instanceof String) {
> > >                  return (String) value;
> > >              }
> > >              else {
> > >                  throw new IllegalArgumentException(
> > >                      "Value is no String (class=" +
> > > value.getClass().getName() + ", value=" + value + ") and component "
> > >                          + component.getClientId (context) + "with path:
> "
> > >                          + getPathToComponent(component)
> > >                          + " does not have a Converter");
> > >              }
> > >          }
> > >
> > >          return converter.getAsString(context, component, value);
> > >      }
> > > -----------
> > >
> > > Maybe your version is missing the lines:
> > >
> > > if (value == null) {
> > >         return "";
> > > }
> > >
> > > Regards,
> > >
> > > Jeff Bischoff
> > > Kenneth L Kurz & Associates, Inc.
> > >
> > > Andrew Robinson wrote:
> > > > Yes that is correct, it was always null but only failed to render the
> > > > 3rd request.
> > > >
> > > > On 11/29/06, Jeff Bischoff <jbischoff@klkurz.com> wrote:
> > > >> Well the reason it doesn't work is because of the null.
> > > >>
> > > >> Are you saying it was set to null the whole time, and only failed
on
> the
> > > >> 3rd request (after having canceled the dialog once)?
> > > >>
> > > >> Regards,
> > > >>
> > > >> Jeff Bischoff
> > > >> Kenneth L Kurz & Associates, Inc.
> > > >>
> > > >> Andrew Robinson wrote:
> > > >> > Found a work around -->
> > > >> > if " value.typeText" is set to one of the values instead of null
I
> > > >> > don't get the exception. What I don't understand is why it works
> the
> > > >> > other times but not the 3rd AJAX call.
> > > >> >
> > > >> > On 11/29/06, Andrew Robinson <andrew.rw.robinson@gmail.com>
wrote:
> > > >> >> I am getting a bit stuck on this one exception. I have two
> > > >> >> selectOneRadio components within an included facelet (source
file)
> > > >> >> that bind to a property on a facelet attribute. The value
is a
> custom
> > > >> >> bean with string properties and the select items have string
> values,
> > > >> >> so no converter should be needed. What is odd is that this
> behavior is
> > > >> >> not constant.
> > > >> >>
> > > >> >> Setup:
> > > >> >> index.xhtml defines this component:
> > > >> >>         <ost:liveReportFilterDialog
> > > >> >>           id="liveReportFilterDlg"
> > > >> >>           ajaxZone="reportListZone"
> > > >> >>
> rendered="#{liveReportBean.filterDialogVisible}"
> > > >> >>
> onAcceptListener="#{liveReportBean.filterDialogAccepted}"
> > > >> >>           onCancelListener="#{
> liveReportBean.filterDialogCanceled}"
> > > >> >>           value="#{liveReportBean.filter}" />
> > > >> >>
> > > >> >> It is this "value" that I use within the
> > > >> "liveReportFilterDialog.xhtml":
> > > >> >>
> > > >> >>   <t:selectOneRadio
> > > >> >>     id="#{id}TypeOptions"
> > > >> >>     value="#{ value.typeText}"
> > > >> >>     layout="pageDirection"
> > > >> >>     required="true">
> > > >> >>     <f:selectItem
> > > >> >>       itemLabel="#{
> msg.liverep_filterdlg_typefilter_graph}"
> > > >> >>       itemValue="osoft/livechart" />
> > > >> >>     <f:selectItem
> > > >> >>
> itemLabel="#{msg.liverep_filterdlg_typefilter_report }"
> > > >> >>       itemValue="osoft/livereport" />
> > > >> >>     <f:selectItem
> > > >> >>
> itemLabel="#{msg.liverep_filterdlg_typefilter_schedule }"
> > > >> >>       itemValue="osoft/liveschedule" />
> > > >> >>   </t:selectOneRadio>
> > > >> >>
> > > >> >> The other radio is:
> > > >> >>
> > > >> >>   <t:selectOneRadio value="#{value.ownerStr}"
> > > >> >>     layout="pageDirection">
> > > >> >>     <f:selectItem itemLabel="#{msg.liverep_filterdlg_item_all
}"
> > > >> >>       itemValue="ALL" />
> > > >> >>     <f:selectItem
> itemLabel="#{msg.liverep_filterdlg_item_owner}"
> > > >> >>       itemValue="CURRENT_USER" />
> > > >> >>   </t:selectOneRadio>
> > > >> >>
> > > >> >>
> > > >> >> This dialog is usually not rendered, I change the value that
the
> > > >> >> rendered attribte points to in an AJAX call ActionListener
method.
> > > >> >> When I click the show, it works. Then, I click the cancel
(close
> the
> > > >> >> dialog), still okay, but when I try to open the dialog again
(3rd
> AJAX
> > > >> >> call) I get the following exception:
> > > >> >> java.lang.IllegalArgumentException: Value is no
> String
> > > >> >>
> (class=org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils$1,
> > > >> >>
> > > >> value=
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils$1@53c483)
> > > >>
> > > >> >>
> > > >> >> and component
> > > >> >>
> > > >>
> zfpPanel:liveReportFilterDlgDialogControl:_gridBagPanelID_3:liveReportFilterDlgTypeOptionswith
> > > >>
> > > >> >>
> > > >> >> path: {Component-Path : [Class:
> > > >> >> javax.faces.component.UIViewRoot,ViewId:
> > > >> >> /pages/liveReport/index.xhtml][Class:
> > > >> >> javax.faces.component.html.HtmlForm,Id:
> zfpForm][Class:
> > > >> >>
> com.outlooksoft.cpm.faces.controls.HtmlGridBagPanel,Id:
> > > >> >> zfpPanel][Class:
> > > >> >>
> com.outlooksoft.cpm.faces.controls.HtmlGridBagCell,Id:
> > > >> >> zfpContentCell][Class:
> > > >> >> com.outlooksoft.cpm.faces.controls.UIAjaxZone,Id:
> zfpBodyZone][Class:
> > > >> >>
> com.outlooksoft.cpm.livereport.controls.HtmlReportFilterDialog,Id:
> > > >> >> liveReportFilterDlg][Class:
> > > >> >> com.outlooksoft.cpm.faces.controls.UIDialog,Id:
> > > >> >> liveReportFilterDlgDialogControl][Class:
> > > >> >>
> com.outlooksoft.cpm.faces.controls.HtmlGridBagPanel,Id:
> > > >> >> _gridBagPanelID_3][Class:
> > > >> >>
> com.outlooksoft.cpm.faces.controls.HtmlGridBagCell,Id:
> > > >> >> _gridBagCellID_29][Class:
> > > >> >>
> org.apache.myfaces.component.html.ext.HtmlSelectOneRadio,Id:
> > > >> >> liveReportFilterDlgTypeOptions]} does not have a
> Converter
> > > >> >>         at
> > > >> >>
> > > >>
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:536)
> > > >>
> > > >> >>
> > > >> >>         at
> > > >> >>
> > > >>
> org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRadioRendererBase.encodeEnd(HtmlRadioRendererBase.java:93)
> > > >>
> > > >> >>
> > > >> >>         at
> > > >> >>
> > > >>
> org.apache.myfaces.renderkit.html.ext.HtmlRadioRenderer.encodeEnd(HtmlRadioRenderer.java:71)
> > > >>
> > > >> >>
> > > >> >>         at
> > > >> >>
> > > >>
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
> > > >> >>         at
> > > >> >>
> > > >>
> org.ajaxanywhere.jsf.ZoneUIComponent.renderComponent(ZoneUIComponent.java
> :90)
> > > >>
> > > >> >>
> > > >> >> ...
> > > >> >>
> > > >> >> The "ownerStr" is "ALL" and the "typeText" is null. I have
been
> unable
> > > >> >> to determine why it fails on this 3rd call and not 1 or 2.
If I
> > > >> >> refresh the page, the dialog is rendered & shown fine.
I verified
> that
> > > >> >> it isn't a problem with the message bundle (msg), as it still
> happens
> > > >> >> if I hard code the itemLabel values.
> > > >> >>
> > > >> >> I am on a 1.1.3 patched version of both Tomahawk and Core.
> > > >> >>
> > > >> >> Any ideas? (also, I haven't yet found the RendererUtils$1
> anonymous
> > > >> >> class yet to find where it is coming from)
> > > >> >>
> > > >> >> Thanks,
> > > >> >> -Andrew
> > > >> >>
> > > >> >
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
>
>

Mime
View raw message