You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Suraj Khurana <su...@hotwaxsystems.com> on 2017/12/29 11:33:53 UTC

Use getCombinedMap instead of getParameter

Hello team,

I noticed in current codebase, at many places we use
*request.getParameter *which
only searches in parameters map. Instead of it, it is recommended to use
*UtilHttp.getCombinedMap(request)* that will create a single map from the
session, attribute, parameter and servlet context map.

This could be a good improvement in the current code base. Please let me
know your thoughts about this.

--
Thanks and Regards,
*Suraj Khurana* | Sr. Enterprise Software Engineer
*HotWax Commerce*  by  *HotWax Systems*
Plot no. 80, Scheme no. 78, Vijay Nagar, Indore, M.P. India 452010

Re: Use getCombinedMap instead of getParameter

Posted by Rishi Solanki <ri...@gmail.com>.
+1 Michael.

Rishi Solanki
Sr Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com
www.hotwax.co

On Fri, Dec 29, 2017 at 6:21 PM, Michael Brohl <mi...@ecomify.de>
wrote:

> Hi Suraj,
>
> I think we should use different ways of getting parameters, attributes
> etc. depending on what is needed in the business logic.
>
> For example, if you only want to use request parameters in an event and
> don't need the overriding mechanism, using UtilHttp.getCombinedMap is
> unnecessary overhead.
>
> I might make sense to refactor code where the business logic first gets
> the parameters and checks for session/request attributes later to override
> them or use them if parameters are missing.
>
> So I think refactoring is a good idea but using it generally throughout
> the codebase should be avoided.
>
> Thanks,
>
> Michael
>
>
> Am 29.12.17 um 12:33 schrieb Suraj Khurana:
>
> Hello team,
>>
>> I noticed in current codebase, at many places we use
>> *request.getParameter *which
>> only searches in parameters map. Instead of it, it is recommended to use
>> *UtilHttp.getCombinedMap(request)* that will create a single map from the
>> session, attribute, parameter and servlet context map.
>>
>> This could be a good improvement in the current code base. Please let me
>> know your thoughts about this.
>>
>> --
>> Thanks and Regards,
>> *Suraj Khurana* | Sr. Enterprise Software Engineer
>> *HotWax Commerce*  by  *HotWax Systems*
>> Plot no. 80, Scheme no. 78, Vijay Nagar, Indore, M.P. India 452010
>>
>>
>
>

Re: Use getCombinedMap instead of getParameter

Posted by Michael Brohl <mi...@ecomify.de>.
Hi Suraj,

I think we should use different ways of getting parameters, attributes 
etc. depending on what is needed in the business logic.

For example, if you only want to use request parameters in an event and 
don't need the overriding mechanism, using UtilHttp.getCombinedMap is 
unnecessary overhead.

I might make sense to refactor code where the business logic first gets 
the parameters and checks for session/request attributes later to 
override them or use them if parameters are missing.

So I think refactoring is a good idea but using it generally throughout 
the codebase should be avoided.

Thanks,

Michael


Am 29.12.17 um 12:33 schrieb Suraj Khurana:
> Hello team,
>
> I noticed in current codebase, at many places we use
> *request.getParameter *which
> only searches in parameters map. Instead of it, it is recommended to use
> *UtilHttp.getCombinedMap(request)* that will create a single map from the
> session, attribute, parameter and servlet context map.
>
> This could be a good improvement in the current code base. Please let me
> know your thoughts about this.
>
> --
> Thanks and Regards,
> *Suraj Khurana* | Sr. Enterprise Software Engineer
> *HotWax Commerce*  by  *HotWax Systems*
> Plot no. 80, Scheme no. 78, Vijay Nagar, Indore, M.P. India 452010
>