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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Anne Jessel
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: [hidden email]

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/
Reply | Threaded
Open this post in threaded view
|

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

Adrian Crum-3
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.
>
>
Reply | Threaded
Open this post in threaded view
|

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

Anne Jessel
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
<[hidden email]> 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: [hidden email]

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/
Reply | Threaded
Open this post in threaded view
|

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

Adrian Crum-3
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
> <[hidden email]>  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.
>>>
>>>
>
>
Reply | Threaded
Open this post in threaded view
|

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

Anne Jessel
That gives a where with "fieldname = '${nullField}'".

Cheers,
Anne.

On 5 September 2011 18:36, Adrian Crum
<[hidden email]> 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
>> <[hidden email]>  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: [hidden email]

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