Use getCombinedMap instead of getParameter

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

Use getCombinedMap instead of getParameter

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

Re: Use getCombinedMap instead of getParameter

Michael Brohl-3
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
>


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Use getCombinedMap instead of getParameter

Rishi Solanki
+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 <[hidden email]>
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
>>
>>
>
>