You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Anne <an...@cohsoft.com.au> on 2011/09/05 05:20:33 UTC

Best fix for OFBIZ-4393 View entity condition-expr doesn't handle null?

Hi

I created Jira OFBIZ-4393 and included a patch. I'm not sure it's the
best solution, and a comment from Hans confirms my uncertainty.

I want a view-entity that uses a condition-expr to check a field for
null. The current code does not support this.

Setting 'value="null"' currently generates "fieldname='null'" in the
where condition. Leaving the value attribute out of the view entity
generates "fieldname=" for the where.

The problem stems from the code that reads the xml returning an empty
String for a missing attribute (and not null). There is code in
ModelViewEntity that checks for a null, but of course that will never
happen.

My patch checks for UtilValidate.isEmpty(value) instead of value ==
null, and so works if we leave the value attribute out of the xml. But
might this cause problems? Would it be better if one had to
specifically state somehow that a test against null was needed? Should
there be a specific way to specify a test against the empty String? I
have not tried to test against an empty String in either current or
patched versions. Is this something that should be supported?

In other places we can use, for example, from-field="null" rather than
value="null", so this problem does not arise. But condition-expr for
view-entity does not have an equivalent of from-field.

Any suggestions as to whether the patch I've already created is the
right one, or whether there's a better approach?

Cheers,
Anne.


-- 
Coherent Software Australia Pty Ltd
PO Box 2773
Cheltenham Vic 3192
Phone: (03) 9585 6788
Fax: (03) 9585 1086
Web: http://www.cohsoft.com.au/
Email: sales@cohsoft.com.au

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/

Re: Best fix for OFBIZ-4393 View entity condition-expr doesn't handle null?

Posted by Anne <an...@cohsoft.com.au>.
That gives a where with "fieldname = '${nullField}'".

Cheers,
Anne.

On 5 September 2011 18:36, Adrian Crum
<ad...@sandglass-software.com> wrote:
> Try value="${nullField}"
>
> -Adrian
>
> On 9/5/2011 9:17 AM, Anne wrote:
>>
>> There is no fromField attribute (or from-field). Do you mean
>> value="nullField" ?
>>
>> I know from-field="null" works in mini-lang.
>>
>> Cheers,
>> Anne.
>>
>> On 5 September 2011 17:29, Adrian Crum
>> <ad...@sandglass-software.com>  wrote:
>>>
>>> I ran into this problem recently while creating entity condition
>>> expressions
>>> in mini-language. Try using fromField="nullField" instead.
>>>
>>> -Adrian
>>>
>>> On 9/5/2011 4:20 AM, Anne wrote:
>>>>
>>>> Hi
>>>>
>>>> I created Jira OFBIZ-4393 and included a patch. I'm not sure it's the
>>>> best solution, and a comment from Hans confirms my uncertainty.
>>>>
>>>> I want a view-entity that uses a condition-expr to check a field for
>>>> null. The current code does not support this.
>>>>
>>>> Setting 'value="null"' currently generates "fieldname='null'" in the
>>>> where condition. Leaving the value attribute out of the view entity
>>>> generates "fieldname=" for the where.
>>>>
>>>> The problem stems from the code that reads the xml returning an empty
>>>> String for a missing attribute (and not null). There is code in
>>>> ModelViewEntity that checks for a null, but of course that will never
>>>> happen.
>>>>
>>>> My patch checks for UtilValidate.isEmpty(value) instead of value ==
>>>> null, and so works if we leave the value attribute out of the xml. But
>>>> might this cause problems? Would it be better if one had to
>>>> specifically state somehow that a test against null was needed? Should
>>>> there be a specific way to specify a test against the empty String? I
>>>> have not tried to test against an empty String in either current or
>>>> patched versions. Is this something that should be supported?
>>>>
>>>> In other places we can use, for example, from-field="null" rather than
>>>> value="null", so this problem does not arise. But condition-expr for
>>>> view-entity does not have an equivalent of from-field.
>>>>
>>>> Any suggestions as to whether the patch I've already created is the
>>>> right one, or whether there's a better approach?
>>>>
>>>> Cheers,
>>>> Anne.
>>>>
>>>>
>>
>>
>



-- 
Coherent Software Australia Pty Ltd
PO Box 2773
Cheltenham Vic 3192
Phone: (03) 9585 6788
Fax: (03) 9585 1086
Web: http://www.cohsoft.com.au/
Email: sales@cohsoft.com.au

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/

Re: Best fix for OFBIZ-4393 View entity condition-expr doesn't handle null?

Posted by Adrian Crum <ad...@sandglass-software.com>.
Try value="${nullField}"

-Adrian

On 9/5/2011 9:17 AM, Anne wrote:
> There is no fromField attribute (or from-field). Do you mean value="nullField" ?
>
> I know from-field="null" works in mini-lang.
>
> Cheers,
> Anne.
>
> On 5 September 2011 17:29, Adrian Crum
> <ad...@sandglass-software.com>  wrote:
>> I ran into this problem recently while creating entity condition expressions
>> in mini-language. Try using fromField="nullField" instead.
>>
>> -Adrian
>>
>> On 9/5/2011 4:20 AM, Anne wrote:
>>> Hi
>>>
>>> I created Jira OFBIZ-4393 and included a patch. I'm not sure it's the
>>> best solution, and a comment from Hans confirms my uncertainty.
>>>
>>> I want a view-entity that uses a condition-expr to check a field for
>>> null. The current code does not support this.
>>>
>>> Setting 'value="null"' currently generates "fieldname='null'" in the
>>> where condition. Leaving the value attribute out of the view entity
>>> generates "fieldname=" for the where.
>>>
>>> The problem stems from the code that reads the xml returning an empty
>>> String for a missing attribute (and not null). There is code in
>>> ModelViewEntity that checks for a null, but of course that will never
>>> happen.
>>>
>>> My patch checks for UtilValidate.isEmpty(value) instead of value ==
>>> null, and so works if we leave the value attribute out of the xml. But
>>> might this cause problems? Would it be better if one had to
>>> specifically state somehow that a test against null was needed? Should
>>> there be a specific way to specify a test against the empty String? I
>>> have not tried to test against an empty String in either current or
>>> patched versions. Is this something that should be supported?
>>>
>>> In other places we can use, for example, from-field="null" rather than
>>> value="null", so this problem does not arise. But condition-expr for
>>> view-entity does not have an equivalent of from-field.
>>>
>>> Any suggestions as to whether the patch I've already created is the
>>> right one, or whether there's a better approach?
>>>
>>> Cheers,
>>> Anne.
>>>
>>>
>
>

Re: Best fix for OFBIZ-4393 View entity condition-expr doesn't handle null?

Posted by Anne <an...@cohsoft.com.au>.
There is no fromField attribute (or from-field). Do you mean value="nullField" ?

I know from-field="null" works in mini-lang.

Cheers,
Anne.

On 5 September 2011 17:29, Adrian Crum
<ad...@sandglass-software.com> wrote:
> I ran into this problem recently while creating entity condition expressions
> in mini-language. Try using fromField="nullField" instead.
>
> -Adrian
>
> On 9/5/2011 4:20 AM, Anne wrote:
>>
>> Hi
>>
>> I created Jira OFBIZ-4393 and included a patch. I'm not sure it's the
>> best solution, and a comment from Hans confirms my uncertainty.
>>
>> I want a view-entity that uses a condition-expr to check a field for
>> null. The current code does not support this.
>>
>> Setting 'value="null"' currently generates "fieldname='null'" in the
>> where condition. Leaving the value attribute out of the view entity
>> generates "fieldname=" for the where.
>>
>> The problem stems from the code that reads the xml returning an empty
>> String for a missing attribute (and not null). There is code in
>> ModelViewEntity that checks for a null, but of course that will never
>> happen.
>>
>> My patch checks for UtilValidate.isEmpty(value) instead of value ==
>> null, and so works if we leave the value attribute out of the xml. But
>> might this cause problems? Would it be better if one had to
>> specifically state somehow that a test against null was needed? Should
>> there be a specific way to specify a test against the empty String? I
>> have not tried to test against an empty String in either current or
>> patched versions. Is this something that should be supported?
>>
>> In other places we can use, for example, from-field="null" rather than
>> value="null", so this problem does not arise. But condition-expr for
>> view-entity does not have an equivalent of from-field.
>>
>> Any suggestions as to whether the patch I've already created is the
>> right one, or whether there's a better approach?
>>
>> Cheers,
>> Anne.
>>
>>
>



-- 
Coherent Software Australia Pty Ltd
PO Box 2773
Cheltenham Vic 3192
Phone: (03) 9585 6788
Fax: (03) 9585 1086
Web: http://www.cohsoft.com.au/
Email: sales@cohsoft.com.au

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/

Re: Best fix for OFBIZ-4393 View entity condition-expr doesn't handle null?

Posted by Adrian Crum <ad...@sandglass-software.com>.
I ran into this problem recently while creating entity condition 
expressions in mini-language. Try using fromField="nullField" instead.

-Adrian

On 9/5/2011 4:20 AM, Anne wrote:
> Hi
>
> I created Jira OFBIZ-4393 and included a patch. I'm not sure it's the
> best solution, and a comment from Hans confirms my uncertainty.
>
> I want a view-entity that uses a condition-expr to check a field for
> null. The current code does not support this.
>
> Setting 'value="null"' currently generates "fieldname='null'" in the
> where condition. Leaving the value attribute out of the view entity
> generates "fieldname=" for the where.
>
> The problem stems from the code that reads the xml returning an empty
> String for a missing attribute (and not null). There is code in
> ModelViewEntity that checks for a null, but of course that will never
> happen.
>
> My patch checks for UtilValidate.isEmpty(value) instead of value ==
> null, and so works if we leave the value attribute out of the xml. But
> might this cause problems? Would it be better if one had to
> specifically state somehow that a test against null was needed? Should
> there be a specific way to specify a test against the empty String? I
> have not tried to test against an empty String in either current or
> patched versions. Is this something that should be supported?
>
> In other places we can use, for example, from-field="null" rather than
> value="null", so this problem does not arise. But condition-expr for
> view-entity does not have an equivalent of from-field.
>
> Any suggestions as to whether the patch I've already created is the
> right one, or whether there's a better approach?
>
> Cheers,
> Anne.
>
>