[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-1576) Query object in framework does not consistently treat "" and null as equivelant.

Chris Rudd (JIRA) jira-events at lists.jboss.org
Thu Jun 28 14:59:57 EDT 2007


Query object in framework does not consistently treat "" and null as equivelant.
--------------------------------------------------------------------------------

                 Key: JBSEAM-1576
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1576
             Project: JBoss Seam
          Issue Type: Bug
    Affects Versions: 1.3.0.ALPHA
            Reporter: Chris Rudd


In Query.isRestrictionParameterSet a null string and an empty string are treated as equivelant (both represent no value set)
BUT in isAnyParameterDirty they are not treated as equivelant. 

In JSF null and empty string are always represented as empty string. Therefore when an input is "not set" an empty string will be set into the backing bean instead of a null. 

This ends up with the isAnyParameterDirty detecting that the default value (null) and the current value (empty string) are different, this causing the query object to reset. This causes the query object to refetch data twice on a request, even though the parameters did not realy change (same exact query is executed both times).

Query.java line 303
    private static boolean isAnyParameterDirty(List<ValueExpression> valueBindings, List<Object> lastParameterValues)
    {
       if (lastParameterValues==null) return true;
       for (int i=0; i<valueBindings.size(); i++)
       {
          Object parameterValue = valueBindings.get(i).getValue();
          Object lastParameterValue = lastParameterValues.get(i);

+        // Treat "" and null as equivelant 
+        if( (lastParameterValue == null && "".equals(parameterValue)) || (parameterValue == null && "".equals(lastParameterValue)) )
+        {
+             continue;
+        }

         if ( parameterValue!=lastParameterValue && ( parameterValue==null || !parameterValue.equals(lastParameterValue) ) )
         {
                 return true;
          }
       }
       return false;
    }





-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list