Frenz ,
Suppose I have two sentence in Beanshell file :- 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); Key i.e partyId in the following sentence will be variable one. 2). partyId = parameters.get("partyId") ; context.put(partyId , UtilMisc.topMap("Key1","Value1")); The converted sentence for the Beanshell statement shown above will be :- 1) context.partyId = [Key1 : "Value1"]; And I am confused about the second one. Can anybody of you give some pointer on it ? -- Ashish Vijaywargiya |
Do you mean like this:
partyId = parameters.partyId; context.partyId = [Key1 : "Value1"]; - Scott 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > Frenz , > > Suppose I have two sentence in Beanshell file :- > > 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > > Key i.e partyId in the following sentence will be variable one. > 2). partyId = parameters.get("partyId") ; > context.put(partyId , UtilMisc.topMap("Key1","Value1")); > > The converted sentence for the Beanshell statement shown above will be :- > > 1) context.partyId = [Key1 : "Value1"]; > > And I am confused about the second one. > Can anybody of you give some pointer on it ? > > -- > Ashish Vijaywargiya > |
Ignore that first line, it shouldn't have been there.
- Scott 2008/6/7 Scott Gray <[hidden email]>: > Do you mean like this: > partyId = parameters.partyId; > context.partyId = [Key1 : "Value1"]; > > - Scott > > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > > Frenz , >> >> Suppose I have two sentence in Beanshell file :- >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); >> >> Key i.e partyId in the following sentence will be variable one. >> 2). partyId = parameters.get("partyId") ; >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); >> >> The converted sentence for the Beanshell statement shown above will be :- >> >> 1) context.partyId = [Key1 : "Value1"]; >> >> And I am confused about the second one. >> Can anybody of you give some pointer on it ? >> >> -- >> Ashish Vijaywargiya >> > > |
In reply to this post by Scott Gray
Another way to express this:
context['partyId'] = [Key1: 'Value1'] HTH, Chanwit ps. single quote is for String, while double quote is for Groovy's String. 2008/6/7 Scott Gray <[hidden email]>: > Do you mean like this: > partyId = parameters.partyId; > context.partyId = [Key1 : "Value1"]; > > - Scott > > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > >> Frenz , >> >> Suppose I have two sentence in Beanshell file :- >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); >> >> Key i.e partyId in the following sentence will be variable one. >> 2). partyId = parameters.get("partyId") ; >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); >> >> The converted sentence for the Beanshell statement shown above will be :- >> >> 1) context.partyId = [Key1 : "Value1"]; >> >> And I am confused about the second one. >> Can anybody of you give some pointer on it ? >> >> -- >> Ashish Vijaywargiya >> > |
A string enclosed in double quotes only becomes a GString if it contains an
${...} expression otherwise single and double quotes are both treated as Strings. http://groovy.codehaus.org/Strings#Strings-GStrings - Scott 2008/6/7 Chanwit Kaewkasi <[hidden email]>: > > ps. single quote is for String, while double quote is for Groovy's String. > > 2008/6/7 Scott Gray <[hidden email]>: > > Do you mean like this: > > partyId = parameters.partyId; > > context.partyId = [Key1 : "Value1"]; > > > > - Scott > > > > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > > > >> Frenz , > >> > >> Suppose I have two sentence in Beanshell file :- > >> > >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > >> > >> Key i.e partyId in the following sentence will be variable one. > >> 2). partyId = parameters.get("partyId") ; > >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); > >> > >> The converted sentence for the Beanshell statement shown above will be > :- > >> > >> 1) context.partyId = [Key1 : "Value1"]; > >> > >> And I am confused about the second one. > >> Can anybody of you give some pointer on it ? > >> > >> -- > >> Ashish Vijaywargiya > >> > > > |
Hello Scott,
You're right. I've confirmed with a compiled class. Anyway, IMHO it's a good practice to use single quotes for a string. Cheers, Chanwit 2008/6/7 Scott Gray <[hidden email]>: > A string enclosed in double quotes only becomes a GString if it contains an > ${...} expression otherwise single and double quotes are both treated as > Strings. > http://groovy.codehaus.org/Strings#Strings-GStrings > > - Scott > > 2008/6/7 Chanwit Kaewkasi <[hidden email]>: > >> >> ps. single quote is for String, while double quote is for Groovy's String. >> >> 2008/6/7 Scott Gray <[hidden email]>: >> > Do you mean like this: >> > partyId = parameters.partyId; >> > context.partyId = [Key1 : "Value1"]; >> > >> > - Scott >> > >> > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: >> > >> >> Frenz , >> >> >> >> Suppose I have two sentence in Beanshell file :- >> >> >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); >> >> >> >> Key i.e partyId in the following sentence will be variable one. >> >> 2). partyId = parameters.get("partyId") ; >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); >> >> >> >> The converted sentence for the Beanshell statement shown above will be >> :- >> >> >> >> 1) context.partyId = [Key1 : "Value1"]; >> >> >> >> And I am confused about the second one. >> >> Can anybody of you give some pointer on it ? >> >> >> >> -- >> >> Ashish Vijaywargiya >> >> >> > >> > |
Scott and Chanwit thanks for your reply.
I think we have deviated from my question ..... reason may be I didn't ask it in proper way. Let me explain it in some other way :- >>Suppose I have two sentence in Beanshell file :- >>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); I am saying that here you are putting the "partyId" as the "key" in the context map and its value will be UtilMisc.toMap("Key1","Value1"). I am fine with its Groovy conversion. The converted groovy sentence for above will be :- context.partyId = [Key1 : "Value1"]; >>Key i.e partyId in the following sentence will be variable one. >>2). partyId = parameters.get("partyId") ; I only wrote the above line to tell that we can get variable value in partyId. >>context.put(partyId , UtilMisc.topMap("Key1","Value1")); In the above sentence you are putting the "value" (that will be variable) of partyId as the "key" and it can be either String or number and then the value of it will be same i.e UtilMisc.topMap("Key1","Value1")). And if we put the groovy conversion of it as same as that of first one in the context then what will be the difference in both the scenario. Please let me know if my explaination is again not to the point. -- Ashish On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <[hidden email]> wrote: > Hello Scott, > > You're right. I've confirmed with a compiled class. > > Anyway, IMHO it's a good practice to use single quotes for a string. > > Cheers, > > Chanwit > > 2008/6/7 Scott Gray <[hidden email]>: > > A string enclosed in double quotes only becomes a GString if it contains > an > > ${...} expression otherwise single and double quotes are both treated as > > Strings. > > http://groovy.codehaus.org/Strings#Strings-GStrings > > > > - Scott > > > > 2008/6/7 Chanwit Kaewkasi <[hidden email]>: > > > >> > >> ps. single quote is for String, while double quote is for Groovy's > String. > >> > >> 2008/6/7 Scott Gray <[hidden email]>: > >> > Do you mean like this: > >> > partyId = parameters.partyId; > >> > context.partyId = [Key1 : "Value1"]; > >> > > >> > - Scott > >> > > >> > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > >> > > >> >> Frenz , > >> >> > >> >> Suppose I have two sentence in Beanshell file :- > >> >> > >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > >> >> > >> >> Key i.e partyId in the following sentence will be variable one. > >> >> 2). partyId = parameters.get("partyId") ; > >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); > >> >> > >> >> The converted sentence for the Beanshell statement shown above will > be > >> :- > >> >> > >> >> 1) context.partyId = [Key1 : "Value1"]; > >> >> > >> >> And I am confused about the second one. > >> >> Can anybody of you give some pointer on it ? > >> >> > >> >> -- > >> >> Ashish Vijaywargiya > >> >> > >> > > >> > > > |
Oh ok I see what you mean, if you do it like this:
partyId = parameters.partyId; context[partyId] = [Key1:"Value1"]; or like this testMap = [(partyId):[Key1:"Value1"]]; -Scott 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > Scott and Chanwit thanks for your reply. > I think we have deviated from my question ..... reason may be I didn't ask > it in proper way. > > Let me explain it in some other way :- > > >>Suppose I have two sentence in Beanshell file :- > >>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > > I am saying that here you are putting the "partyId" as the "key" in the > context map and its value will be UtilMisc.toMap("Key1","Value1"). > I am fine with its Groovy conversion. > The converted groovy sentence for above will be :- > context.partyId = [Key1 : "Value1"]; > > >>Key i.e partyId in the following sentence will be variable one. > >>2). partyId = parameters.get("partyId") ; > I only wrote the above line to tell that we can get variable value in > partyId. > >>context.put(partyId , UtilMisc.topMap("Key1","Value1")); > > In the above sentence you are putting the "value" (that will be variable) > of > partyId as the "key" and it can be either String or number and then the > value of it will be same i.e UtilMisc.topMap("Key1","Value1")). > And if we put the groovy conversion of it as same as that of first one in > the context then what will be the difference in both the scenario. > > Please let me know if my explaination is again not to the point. > > -- > Ashish > > > > On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <[hidden email]> > wrote: > > > Hello Scott, > > > > You're right. I've confirmed with a compiled class. > > > > Anyway, IMHO it's a good practice to use single quotes for a string. > > > > Cheers, > > > > Chanwit > > > > 2008/6/7 Scott Gray <[hidden email]>: > > > A string enclosed in double quotes only becomes a GString if it > contains > > an > > > ${...} expression otherwise single and double quotes are both treated > as > > > Strings. > > > http://groovy.codehaus.org/Strings#Strings-GStrings > > > > > > - Scott > > > > > > 2008/6/7 Chanwit Kaewkasi <[hidden email]>: > > > > > >> > > >> ps. single quote is for String, while double quote is for Groovy's > > String. > > >> > > >> 2008/6/7 Scott Gray <[hidden email]>: > > >> > Do you mean like this: > > >> > partyId = parameters.partyId; > > >> > context.partyId = [Key1 : "Value1"]; > > >> > > > >> > - Scott > > >> > > > >> > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > > >> > > > >> >> Frenz , > > >> >> > > >> >> Suppose I have two sentence in Beanshell file :- > > >> >> > > >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > > >> >> > > >> >> Key i.e partyId in the following sentence will be variable one. > > >> >> 2). partyId = parameters.get("partyId") ; > > >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); > > >> >> > > >> >> The converted sentence for the Beanshell statement shown above will > > be > > >> :- > > >> >> > > >> >> 1) context.partyId = [Key1 : "Value1"]; > > >> >> > > >> >> And I am confused about the second one. > > >> >> Can anybody of you give some pointer on it ? > > >> >> > > >> >> -- > > >> >> Ashish Vijaywargiya > > >> >> > > >> > > > >> > > > > > > |
Oh... that's perfect Scott.
Thanks man..... you are soo quick :-) -- Ashish On Sat, Jun 7, 2008 at 6:14 AM, Scott Gray <[hidden email]> wrote: > Oh ok I see what you mean, if you do it like this: > partyId = parameters.partyId; > context[partyId] = [Key1:"Value1"]; > > or like this > testMap = [(partyId):[Key1:"Value1"]]; > > -Scott > > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > > > Scott and Chanwit thanks for your reply. > > I think we have deviated from my question ..... reason may be I didn't > ask > > it in proper way. > > > > Let me explain it in some other way :- > > > > >>Suppose I have two sentence in Beanshell file :- > > >>1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > > > > I am saying that here you are putting the "partyId" as the "key" in the > > context map and its value will be UtilMisc.toMap("Key1","Value1"). > > I am fine with its Groovy conversion. > > The converted groovy sentence for above will be :- > > context.partyId = [Key1 : "Value1"]; > > > > >>Key i.e partyId in the following sentence will be variable one. > > >>2). partyId = parameters.get("partyId") ; > > I only wrote the above line to tell that we can get variable value in > > partyId. > > >>context.put(partyId , UtilMisc.topMap("Key1","Value1")); > > > > In the above sentence you are putting the "value" (that will be variable) > > of > > partyId as the "key" and it can be either String or number and then the > > value of it will be same i.e UtilMisc.topMap("Key1","Value1")). > > And if we put the groovy conversion of it as same as that of first one in > > the context then what will be the difference in both the scenario. > > > > Please let me know if my explaination is again not to the point. > > > > -- > > Ashish > > > > > > > > On Sat, Jun 7, 2008 at 4:56 AM, Chanwit Kaewkasi <[hidden email]> > > wrote: > > > > > Hello Scott, > > > > > > You're right. I've confirmed with a compiled class. > > > > > > Anyway, IMHO it's a good practice to use single quotes for a string. > > > > > > Cheers, > > > > > > Chanwit > > > > > > 2008/6/7 Scott Gray <[hidden email]>: > > > > A string enclosed in double quotes only becomes a GString if it > > contains > > > an > > > > ${...} expression otherwise single and double quotes are both treated > > as > > > > Strings. > > > > http://groovy.codehaus.org/Strings#Strings-GStrings > > > > > > > > - Scott > > > > > > > > 2008/6/7 Chanwit Kaewkasi <[hidden email]>: > > > > > > > >> > > > >> ps. single quote is for String, while double quote is for Groovy's > > > String. > > > >> > > > >> 2008/6/7 Scott Gray <[hidden email]>: > > > >> > Do you mean like this: > > > >> > partyId = parameters.partyId; > > > >> > context.partyId = [Key1 : "Value1"]; > > > >> > > > > >> > - Scott > > > >> > > > > >> > 2008/6/7 Ashish Vijaywargiya <[hidden email]>: > > > >> > > > > >> >> Frenz , > > > >> >> > > > >> >> Suppose I have two sentence in Beanshell file :- > > > >> >> > > > >> >> 1). context.put("partyId" , UtilMisc.toMap("Key1","Value1")); > > > >> >> > > > >> >> Key i.e partyId in the following sentence will be variable one. > > > >> >> 2). partyId = parameters.get("partyId") ; > > > >> >> context.put(partyId , UtilMisc.topMap("Key1","Value1")); > > > >> >> > > > >> >> The converted sentence for the Beanshell statement shown above > will > > > be > > > >> :- > > > >> >> > > > >> >> 1) context.partyId = [Key1 : "Value1"]; > > > >> >> > > > >> >> And I am confused about the second one. > > > >> >> Can anybody of you give some pointer on it ? > > > >> >> > > > >> >> -- > > > >> >> Ashish Vijaywargiya > > > >> >> > > > >> > > > > >> > > > > > > > > > > |
Free forum by Nabble | Edit this page |