Groovy question regarding passing html parameters

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

Groovy question regarding passing html parameters

Pierre Smits
In a url I pass following parameters:

?profile=10000&experience=10000,100010

In a groovy file I get the parameters....
parameter.profile
parameter.experience

My question is: how do I get the delegator to find entities in the database
based on both parameter.profile and parameter.experience?

In all the other codes in groovy files that I see it seems that parameters
have only 1 value... Or I might be overlooking one...

Regards,,

Pierre
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
Hi Pierre,

You'll want to use delegator.findList(...) with an EntityOperator.IN condition for the experience field.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 20/08/2010, at 10:31 PM, Pierre Smits wrote:

> In a url I pass following parameters:
>
> ?profile=10000&experience=10000,100010
>
> In a groovy file I get the parameters....
> parameter.profile
> parameter.experience
>
> My question is: how do I get the delegator to find entities in the database
> based on both parameter.profile and parameter.experience?
>
> In all the other codes in groovy files that I see it seems that parameters
> have only 1 value... Or I might be overlooking one...
>
> Regards,,
>
> Pierre


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

Re: Groovy question regarding passing html parameters

Jacques Le Roux
Administrator
In reply to this post by Pierre Smits
http://en.wikipedia.org/wiki/Query_string

Jacques

Pierre Smits wrote:

> In a url I pass following parameters:
>
> ?profile=10000&experience=10000,100010
>
> In a groovy file I get the parameters....
> parameter.profile
> parameter.experience
>
> My question is: how do I get the delegator to find entities in the database
> based on both parameter.profile and parameter.experience?
>
> In all the other codes in groovy files that I see it seems that parameters
> have only 1 value... Or I might be overlooking one...
>
> Regards,,
>
> Pierre

Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Pierre Smits
In reply to this post by Scott Gray-2
Hi Scott,

Thanks for the pointer!

Unfortunately, I am a total groovy-newbie....

Would
selectedExperiences = parameter.selectedExperiences;
if (selectedExperiences==""){
    experienceItemList = delegator.findByAnd("ProfileExperience",
[profileOwnerId : profileOwnerId]);
    }
    else{
    experienceItemList = delegator.findList("ProfileExperience",
[experienceId : selectedExperiences]);

    }

do the trick?

Regards,

Pierre


2010/8/20 Scott Gray <[hidden email]>

> Hi Pierre,
>
> You'll want to use delegator.findList(...) with an EntityOperator.IN
> condition for the experience field.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>
> > In a url I pass following parameters:
> >
> > ?profile=10000&experience=10000,100010
> >
> > In a groovy file I get the parameters....
> > parameter.profile
> > parameter.experience
> >
> > My question is: how do I get the delegator to find entities in the
> database
> > based on both parameter.profile and parameter.experience?
> >
> > In all the other codes in groovy files that I see it seems that
> parameters
> > have only 1 value... Or I might be overlooking one...
> >
> > Regards,,
> >
> > Pierre
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Jacques Le Roux
Administrator
In reply to this post by Jacques Le Roux
BTW I leanrt something reading this article:
http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2

Too bad, ";" does not seem to be widely supported :/

Jacques

Jacques Le Roux wrote:

> http://en.wikipedia.org/wiki/Query_string
>
> Jacques
>
> Pierre Smits wrote:
>> In a url I pass following parameters:
>>
>> ?profile=10000&experience=10000,100010
>>
>> In a groovy file I get the parameters....
>> parameter.profile
>> parameter.experience
>>
>> My question is: how do I get the delegator to find entities in the database
>> based on both parameter.profile and parameter.experience?
>>
>> In all the other codes in groovy files that I see it seems that parameters
>> have only 1 value... Or I might be overlooking one...
>>
>> Regards,,
>>
>> Pierre

Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Michał Cukierman
In reply to this post by Scott Gray-2
Scott,

Maybe I am wrong but ... EntityOperator.IN is used to filter objects
that you already have. From the developer point of view it's very bad
practice.

For example:
1) You need to query for 1000 products
2) You use EntityOperator and do a second query to "filter" those, just
to get ,lets say, 10 products as a result.

You can do it within a single query (not two of them), and you can fetch
just 10 objects from a database not 1010.

It's complitely OK If you already have objects passed after
EntityOperator.IN in a java collection, but in this case:
You need to do it specialy for creating second DB call.

There should be a method for doing sth like:
EntityCondition.makeCondition("shipmentId", EntityOperator.IN,
CustomWhereCondition).
There should be extended methods for making joins.
As long as those do not exist - we should at least try use PROPER SQL
calls.

>From my perspective, Ofbiz is much more limited 'cause of such code.

Regards,
Michał



Dnia 2010-08-20, piÄ… o godzinie 23:27 +1200, Scott Gray pisze:

> Hi Pierre,
>
> You'll want to use delegator.findList(...) with an EntityOperator.IN condition for the experience field.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>
> > In a url I pass following parameters:
> >
> > ?profile=10000&experience=10000,100010
> >
> > In a groovy file I get the parameters....
> > parameter.profile
> > parameter.experience
> >
> > My question is: how do I get the delegator to find entities in the database
> > based on both parameter.profile and parameter.experience?
> >
> > In all the other codes in groovy files that I see it seems that parameters
> > have only 1 value... Or I might be overlooking one...
> >
> > Regards,,
> >
> > Pierre
>

Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

James McGill-5
2010/8/20 Michał Cukierman <[hidden email]>

>
> There should be a method for doing sth like:
> EntityCondition.makeCondition("shipmentId", EntityOperator.IN,
> CustomWhereCondition).
> There should be extended methods for making joins.
> As long as those do not exist - we should at least try use P
>

"IN" (and "NOT IN") conditions should be definable on view entities.  The
XSD defines an "IN" operator for entity-conditions and implies that
entity-conditions are valid in view entities, but I couldn't get this to
work.  I can't tell how you would represent the right hand side of "IN",
either.  There is a TODO comment in the XSD for "NOT IN".

I'm sure the implementation of this becomes rather complicated for all the
different SQL flavors that OFBiz supports, especially when you take it to
the next level, "SELECT" on the right hand side of "IN".

Opentaps has a "Query Tool" to deal with situations where implementing a
query concept is beyond what the entity delegator will do,
in order to support things like JDBC PreparedStatements, "IN" clauses and
subselects.

http://www.opentaps.org/docs/index.php/Using_the_Query_Tool

Notice that this approach was abandoned in favor of Hibernate integration.
With that, I would personally just punt in this situation, get a connection
from the delegator, and deal with the results as a Map.  Before I did that,
I'd want to make sure that my assumptions are correct (performance of
subsequent cached queries, cost of traversing an EntityListIterator for
conditions, selecting on a view or DVE, etc.)

--
James McGill
Phoenix AZ
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
In reply to this post by Michał Cukierman
Hi Michal,

To be honest I'm not really sure what you're talking about?

I was simply suggesting the Pierre could do the following for his query:
condList = []
condList.add(EntityCondition.makeCondition("profileOwnerId", profileOwnerId))
if (selectedExperiences) {
    condList.add(EntityCondition.makeCondition("experienceId", EntityOperator.IN, selectedExperiences as List)
}
cond = EntityCondition.makeCondition(condList);
results = delegator.findList("ProfileExperience", condList, null, null, null, false);

Which should result in the following query (assuming selectedExperiences has content):
SELECT * FROM PROFILE_EXPERIENCE WHERE PROFILE_ID = ? AND EXPERIENCE_ID IN (?)
Are you saying there is some sort of problem with this type of query?

Regards
Scott

On 21/08/2010, at 1:58 AM, Michał Cukierman wrote:

> Scott,
>
> Maybe I am wrong but ... EntityOperator.IN is used to filter objects
> that you already have. From the developer point of view it's very bad
> practice.
>
> For example:
> 1) You need to query for 1000 products
> 2) You use EntityOperator and do a second query to "filter" those, just
> to get ,lets say, 10 products as a result.
>
> You can do it within a single query (not two of them), and you can fetch
> just 10 objects from a database not 1010.
>
> It's complitely OK If you already have objects passed after
> EntityOperator.IN in a java collection, but in this case:
> You need to do it specialy for creating second DB call.
>
> There should be a method for doing sth like:
> EntityCondition.makeCondition("shipmentId", EntityOperator.IN,
> CustomWhereCondition).
> There should be extended methods for making joins.
> As long as those do not exist - we should at least try use PROPER SQL
> calls.
>
>> From my perspective, Ofbiz is much more limited 'cause of such code.
>
> Regards,
> Michał
>
>
>
> Dnia 2010-08-20, piÄ… o godzinie 23:27 +1200, Scott Gray pisze:
>> Hi Pierre,
>>
>> You'll want to use delegator.findList(...) with an EntityOperator.IN condition for the experience field.
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>>
>>> In a url I pass following parameters:
>>>
>>> ?profile=10000&experience=10000,100010
>>>
>>> In a groovy file I get the parameters....
>>> parameter.profile
>>> parameter.experience
>>>
>>> My question is: how do I get the delegator to find entities in the database
>>> based on both parameter.profile and parameter.experience?
>>>
>>> In all the other codes in groovy files that I see it seems that parameters
>>> have only 1 value... Or I might be overlooking one...
>>>
>>> Regards,,
>>>
>>> Pierre
>>
>


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

Re: Groovy question regarding passing html parameters

Scott Gray-2
In reply to this post by Pierre Smits
Hi Pierre,

See my other response to Michal for the correct code, it was only from memory though so may not actually work without tweaking.

Regards
Scott

On 21/08/2010, at 12:02 AM, Pierre Smits wrote:

> Hi Scott,
>
> Thanks for the pointer!
>
> Unfortunately, I am a total groovy-newbie....
>
> Would
> selectedExperiences = parameter.selectedExperiences;
> if (selectedExperiences==""){
>    experienceItemList = delegator.findByAnd("ProfileExperience",
> [profileOwnerId : profileOwnerId]);
>    }
>    else{
>    experienceItemList = delegator.findList("ProfileExperience",
> [experienceId : selectedExperiences]);
>
>    }
>
> do the trick?
>
> Regards,
>
> Pierre
>
>
> 2010/8/20 Scott Gray <[hidden email]>
>
>> Hi Pierre,
>>
>> You'll want to use delegator.findList(...) with an EntityOperator.IN
>> condition for the experience field.
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>>
>>> In a url I pass following parameters:
>>>
>>> ?profile=10000&experience=10000,100010
>>>
>>> In a groovy file I get the parameters....
>>> parameter.profile
>>> parameter.experience
>>>
>>> My question is: how do I get the delegator to find entities in the
>> database
>>> based on both parameter.profile and parameter.experience?
>>>
>>> In all the other codes in groovy files that I see it seems that
>> parameters
>>> have only 1 value... Or I might be overlooking one...
>>>
>>> Regards,,
>>>
>>> Pierre
>>
>>


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

Re: Groovy question regarding passing html parameters

Michał Cukierman
In reply to this post by Scott Gray-2
Hi Scott,

Thats why I started with: "Maybe I am wrong".
The situation you describing is ok, when both parameters exists in one
table. The question is not clear in that case, thats why we
misunderstood each other. I was thinking about getting some sort of
objects from related objects, based on two parameters.

Sorry for my criticism, but I am stil confused about some limitations in
Ofbiz persistence Layer (which is in fact graet - but limited). Today I
get "initial" Product data I will put into ofbiz. It's around 400 000
ProductCategories + a lot of criterias and extended model. So at the
moment, optimalization is my key point.

Regards,
Michał



Dnia 2010-08-21, sob o godzinie 11:41 +1200, Scott Gray pisze:

> Hi Michal,
>
> To be honest I'm not really sure what you're talking about?
>
> I was simply suggesting the Pierre could do the following for his query:
> condList = []
> condList.add(EntityCondition.makeCondition("profileOwnerId", profileOwnerId))
> if (selectedExperiences) {
>     condList.add(EntityCondition.makeCondition("experienceId", EntityOperator.IN, selectedExperiences as List)
> }
> cond = EntityCondition.makeCondition(condList);
> results = delegator.findList("ProfileExperience", condList, null, null, null, false);
>
> Which should result in the following query (assuming selectedExperiences has content):
> SELECT * FROM PROFILE_EXPERIENCE WHERE PROFILE_ID = ? AND EXPERIENCE_ID IN (?)
> Are you saying there is some sort of problem with this type of query?
>
> Regards
> Scott
>
> On 21/08/2010, at 1:58 AM, Michał Cukierman wrote:
>
> > Scott,
> >
> > Maybe I am wrong but ... EntityOperator.IN is used to filter objects
> > that you already have. From the developer point of view it's very bad
> > practice.
> >
> > For example:
> > 1) You need to query for 1000 products
> > 2) You use EntityOperator and do a second query to "filter" those, just
> > to get ,lets say, 10 products as a result.
> >
> > You can do it within a single query (not two of them), and you can fetch
> > just 10 objects from a database not 1010.
> >
> > It's complitely OK If you already have objects passed after
> > EntityOperator.IN in a java collection, but in this case:
> > You need to do it specialy for creating second DB call.
> >
> > There should be a method for doing sth like:
> > EntityCondition.makeCondition("shipmentId", EntityOperator.IN,
> > CustomWhereCondition).
> > There should be extended methods for making joins.
> > As long as those do not exist - we should at least try use PROPER SQL
> > calls.
> >
> >> From my perspective, Ofbiz is much more limited 'cause of such code.
> >
> > Regards,
> > Michał
> >
> >
> >
> > Dnia 2010-08-20, piÄ… o godzinie 23:27 +1200, Scott Gray pisze:
> >> Hi Pierre,
> >>
> >> You'll want to use delegator.findList(...) with an EntityOperator.IN condition for the experience field.
> >>
> >> Regards
> >> Scott
> >>
> >> HotWax Media
> >> http://www.hotwaxmedia.com
> >>
> >> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> >>
> >>> In a url I pass following parameters:
> >>>
> >>> ?profile=10000&experience=10000,100010
> >>>
> >>> In a groovy file I get the parameters....
> >>> parameter.profile
> >>> parameter.experience
> >>>
> >>> My question is: how do I get the delegator to find entities in the database
> >>> based on both parameter.profile and parameter.experience?
> >>>
> >>> In all the other codes in groovy files that I see it seems that parameters
> >>> have only 1 value... Or I might be overlooking one...
> >>>
> >>> Regards,,
> >>>
> >>> Pierre
> >>
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Pierre Smits
In reply to this post by Scott Gray-2
Hi Scott,

Thanks for the pointer. I think it should be on the money.... However after
some tweaking I got following error:

<p>Problems with the response writer&#47;output stream&#58;
 org.ofbiz.widget.screen.ScreenRenderException&#58;
 Error rendering screen
&#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
 groovy.lang.MissingPropertyException&#58; No such property&#58;
 EntityCondition for class&#58; ProfileExperiences &#40;No such
property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
</p>


The complete code in the groovy file is:
import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.entity.util.*;
import org.ofbiz.party.contact.*;
import javolution.util.FastMap;

List experienceItems = [];

profileOwnerId = profileSummary.profileOwnerId;
selectedExperiences = parameters.experienceSelected;

condList = [];
condList.add(EntityCondition.makeCondition("profileOwnerId",
profileOwnerId));
if (selectedExperiences) {
   condList.add(EntityCondition.makeCondition("experienceId",
EntityOperator.IN, selectedExperiences as List));
}
cond = EntityCondition.makeCondition(condList);
experienceItemList = delegator.findList("ProfileExperience", cond, null,
null, null, false);

if (experienceItemList) {
    experienceItemList.each { profileExperience ->
        experienceDesc = profileExperience.experienceDesc;
        experienceStartDate = profileExperience.experienceStartDate;
        experienceEndDate = profileExperience.experienceEndDate;
        experienceCustomerId = profileExperience.experienceCustomerId;
        experienceIndustryId = profileExperience.experienceIndustryId;
        experienceProjectId = profileExperience.experienceProjectId;
        experienceTaskId = profileExperience.experienceTaskId;
        experienceBackground = profileExperience.experienceBackground;
        experienceContext = profileExperience.experienceContext;
        experienceTask = profileExperience.experienceTask;
        experienceMethods = profileExperience.experienceMethods;
        experienceTools = profileExperience.experienceTools;

        Map experienceItemMap = FastMap.newInstance();
        experienceItemMap.putAll((Map) profileExperience);

        experienceItems.add(experienceItemMap);
    }
    context.experienceItems = experienceItems;
    }

Any suggestions?

Regards,

Pierre


2010/8/21 Scott Gray <[hidden email]>

> Hi Pierre,
>
> See my other response to Michal for the correct code, it was only from
> memory though so may not actually work without tweaking.
>
> Regards
> Scott
>
> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
>
> > Hi Scott,
> >
> > Thanks for the pointer!
> >
> > Unfortunately, I am a total groovy-newbie....
> >
> > Would
> > selectedExperiences = parameter.selectedExperiences;
> > if (selectedExperiences==""){
> >    experienceItemList = delegator.findByAnd("ProfileExperience",
> > [profileOwnerId : profileOwnerId]);
> >    }
> >    else{
> >    experienceItemList = delegator.findList("ProfileExperience",
> > [experienceId : selectedExperiences]);
> >
> >    }
> >
> > do the trick?
> >
> > Regards,
> >
> > Pierre
> >
> >
> > 2010/8/20 Scott Gray <[hidden email]>
> >
> >> Hi Pierre,
> >>
> >> You'll want to use delegator.findList(...) with an EntityOperator.IN
> >> condition for the experience field.
> >>
> >> Regards
> >> Scott
> >>
> >> HotWax Media
> >> http://www.hotwaxmedia.com
> >>
> >> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> >>
> >>> In a url I pass following parameters:
> >>>
> >>> ?profile=10000&experience=10000,100010
> >>>
> >>> In a groovy file I get the parameters....
> >>> parameter.profile
> >>> parameter.experience
> >>>
> >>> My question is: how do I get the delegator to find entities in the
> >> database
> >>> based on both parameter.profile and parameter.experience?
> >>>
> >>> In all the other codes in groovy files that I see it seems that
> >> parameters
> >>> have only 1 value... Or I might be overlooking one...
> >>>
> >>> Regards,,
> >>>
> >>> Pierre
> >>
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Pierre Smits
The error more readable:

Problems with the response writer/output stream:
org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
[component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
groovy.lang.MissingPropertyException: No such property: EntityCondition for
class: ProfileExperiences (No such property: EntityCondition for class:
ProfileExperiences)

Regards,

Pierre

2010/8/23 Pierre Smits <[hidden email]>

> Hi Scott,
>
> Thanks for the pointer. I think it should be on the money.... However after
> some tweaking I got following error:
>
> <p>Problems with the response writer&#47;output stream&#58;
>
>  org.ofbiz.widget.screen.ScreenRenderException&#58;
>  Error rendering screen &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
>
>  groovy.lang.MissingPropertyException&#58; No such property&#58;
>  EntityCondition for class&#58; ProfileExperiences &#40;No such property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
>
> </p>
>
>
> The complete code in the groovy file is:
> import org.ofbiz.base.util.*;
> import org.ofbiz.entity.*;
> import org.ofbiz.entity.util.*;
> import org.ofbiz.party.contact.*;
> import javolution.util.FastMap;
>
> List experienceItems = [];
>
> profileOwnerId = profileSummary.profileOwnerId;
> selectedExperiences = parameters.experienceSelected;
>
>
> condList = [];
> condList.add(EntityCondition.makeCondition("profileOwnerId",
> profileOwnerId));
> if (selectedExperiences) {
>    condList.add(EntityCondition.makeCondition("experienceId",
> EntityOperator.IN, selectedExperiences as List));
> }
> cond = EntityCondition.makeCondition(condList);
> experienceItemList = delegator.findList("ProfileExperience", cond, null,
> null, null, false);
>
> if (experienceItemList) {
>     experienceItemList.each { profileExperience ->
>         experienceDesc = profileExperience.experienceDesc;
>         experienceStartDate = profileExperience.experienceStartDate;
>         experienceEndDate = profileExperience.experienceEndDate;
>         experienceCustomerId = profileExperience.experienceCustomerId;
>         experienceIndustryId = profileExperience.experienceIndustryId;
>         experienceProjectId = profileExperience.experienceProjectId;
>         experienceTaskId = profileExperience.experienceTaskId;
>         experienceBackground = profileExperience.experienceBackground;
>         experienceContext = profileExperience.experienceContext;
>         experienceTask = profileExperience.experienceTask;
>         experienceMethods = profileExperience.experienceMethods;
>         experienceTools = profileExperience.experienceTools;
>
>         Map experienceItemMap = FastMap.newInstance();
>         experienceItemMap.putAll((Map) profileExperience);
>
>         experienceItems.add(experienceItemMap);
>     }
>     context.experienceItems = experienceItems;
>     }
>
> Any suggestions?
>
> Regards,
>
> Pierre
>
>
> 2010/8/21 Scott Gray <[hidden email]>
>
> Hi Pierre,
>>
>> See my other response to Michal for the correct code, it was only from
>> memory though so may not actually work without tweaking.
>>
>> Regards
>> Scott
>>
>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
>>
>> > Hi Scott,
>> >
>> > Thanks for the pointer!
>> >
>> > Unfortunately, I am a total groovy-newbie....
>> >
>> > Would
>> > selectedExperiences = parameter.selectedExperiences;
>> > if (selectedExperiences==""){
>> >    experienceItemList = delegator.findByAnd("ProfileExperience",
>> > [profileOwnerId : profileOwnerId]);
>> >    }
>> >    else{
>> >    experienceItemList = delegator.findList("ProfileExperience",
>> > [experienceId : selectedExperiences]);
>> >
>> >    }
>> >
>> > do the trick?
>> >
>> > Regards,
>> >
>> > Pierre
>> >
>> >
>> > 2010/8/20 Scott Gray <[hidden email]>
>> >
>> >> Hi Pierre,
>> >>
>> >> You'll want to use delegator.findList(...) with an EntityOperator.IN
>> >> condition for the experience field.
>> >>
>> >> Regards
>> >> Scott
>> >>
>> >> HotWax Media
>> >> http://www.hotwaxmedia.com
>> >>
>> >> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>> >>
>> >>> In a url I pass following parameters:
>> >>>
>> >>> ?profile=10000&experience=10000,100010
>> >>>
>> >>> In a groovy file I get the parameters....
>> >>> parameter.profile
>> >>> parameter.experience
>> >>>
>> >>> My question is: how do I get the delegator to find entities in the
>> >> database
>> >>> based on both parameter.profile and parameter.experience?
>> >>>
>> >>> In all the other codes in groovy files that I see it seems that
>> >> parameters
>> >>> have only 1 value... Or I might be overlooking one...
>> >>>
>> >>> Regards,,
>> >>>
>> >>> Pierre
>> >>
>> >>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
Hi Pierre,

You need to add the EntityCondition class to the list of imports:
import org.ofbiz.entity.condition.EntityCondition;

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 23/08/2010, at 7:49 PM, Pierre Smits wrote:

> The error more readable:
>
> Problems with the response writer/output stream:
> org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> groovy.lang.MissingPropertyException: No such property: EntityCondition for
> class: ProfileExperiences (No such property: EntityCondition for class:
> ProfileExperiences)
>
> Regards,
>
> Pierre
>
> 2010/8/23 Pierre Smits <[hidden email]>
>
>> Hi Scott,
>>
>> Thanks for the pointer. I think it should be on the money.... However after
>> some tweaking I got following error:
>>
>> <p>Problems with the response writer&#47;output stream&#58;
>>
>> org.ofbiz.widget.screen.ScreenRenderException&#58;
>> Error rendering screen &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
>>
>> groovy.lang.MissingPropertyException&#58; No such property&#58;
>> EntityCondition for class&#58; ProfileExperiences &#40;No such property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
>>
>> </p>
>>
>>
>> The complete code in the groovy file is:
>> import org.ofbiz.base.util.*;
>> import org.ofbiz.entity.*;
>> import org.ofbiz.entity.util.*;
>> import org.ofbiz.party.contact.*;
>> import javolution.util.FastMap;
>>
>> List experienceItems = [];
>>
>> profileOwnerId = profileSummary.profileOwnerId;
>> selectedExperiences = parameters.experienceSelected;
>>
>>
>> condList = [];
>> condList.add(EntityCondition.makeCondition("profileOwnerId",
>> profileOwnerId));
>> if (selectedExperiences) {
>>   condList.add(EntityCondition.makeCondition("experienceId",
>> EntityOperator.IN, selectedExperiences as List));
>> }
>> cond = EntityCondition.makeCondition(condList);
>> experienceItemList = delegator.findList("ProfileExperience", cond, null,
>> null, null, false);
>>
>> if (experienceItemList) {
>>    experienceItemList.each { profileExperience ->
>>        experienceDesc = profileExperience.experienceDesc;
>>        experienceStartDate = profileExperience.experienceStartDate;
>>        experienceEndDate = profileExperience.experienceEndDate;
>>        experienceCustomerId = profileExperience.experienceCustomerId;
>>        experienceIndustryId = profileExperience.experienceIndustryId;
>>        experienceProjectId = profileExperience.experienceProjectId;
>>        experienceTaskId = profileExperience.experienceTaskId;
>>        experienceBackground = profileExperience.experienceBackground;
>>        experienceContext = profileExperience.experienceContext;
>>        experienceTask = profileExperience.experienceTask;
>>        experienceMethods = profileExperience.experienceMethods;
>>        experienceTools = profileExperience.experienceTools;
>>
>>        Map experienceItemMap = FastMap.newInstance();
>>        experienceItemMap.putAll((Map) profileExperience);
>>
>>        experienceItems.add(experienceItemMap);
>>    }
>>    context.experienceItems = experienceItems;
>>    }
>>
>> Any suggestions?
>>
>> Regards,
>>
>> Pierre
>>
>>
>> 2010/8/21 Scott Gray <[hidden email]>
>>
>> Hi Pierre,
>>>
>>> See my other response to Michal for the correct code, it was only from
>>> memory though so may not actually work without tweaking.
>>>
>>> Regards
>>> Scott
>>>
>>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
>>>
>>>> Hi Scott,
>>>>
>>>> Thanks for the pointer!
>>>>
>>>> Unfortunately, I am a total groovy-newbie....
>>>>
>>>> Would
>>>> selectedExperiences = parameter.selectedExperiences;
>>>> if (selectedExperiences==""){
>>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
>>>> [profileOwnerId : profileOwnerId]);
>>>>   }
>>>>   else{
>>>>   experienceItemList = delegator.findList("ProfileExperience",
>>>> [experienceId : selectedExperiences]);
>>>>
>>>>   }
>>>>
>>>> do the trick?
>>>>
>>>> Regards,
>>>>
>>>> Pierre
>>>>
>>>>
>>>> 2010/8/20 Scott Gray <[hidden email]>
>>>>
>>>>> Hi Pierre,
>>>>>
>>>>> You'll want to use delegator.findList(...) with an EntityOperator.IN
>>>>> condition for the experience field.
>>>>>
>>>>> Regards
>>>>> Scott
>>>>>
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>>
>>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>>>>>
>>>>>> In a url I pass following parameters:
>>>>>>
>>>>>> ?profile=10000&experience=10000,100010
>>>>>>
>>>>>> In a groovy file I get the parameters....
>>>>>> parameter.profile
>>>>>> parameter.experience
>>>>>>
>>>>>> My question is: how do I get the delegator to find entities in the
>>>>> database
>>>>>> based on both parameter.profile and parameter.experience?
>>>>>>
>>>>>> In all the other codes in groovy files that I see it seems that
>>>>> parameters
>>>>>> have only 1 value... Or I might be overlooking one...
>>>>>>
>>>>>> Regards,,
>>>>>>
>>>>>> Pierre
>>>>>
>>>>>
>>>
>>>
>>


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

Re: Groovy question regarding passing html parameters

Pierre Smits
Hi Scott,

I added the import. Unfortunately, the result is the same error.

Regards,

Pierre


2010/8/23 Scott Gray <[hidden email]>

> Hi Pierre,
>
> You need to add the EntityCondition class to the list of imports:
> import org.ofbiz.entity.condition.EntityCondition;
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
>
> > The error more readable:
> >
> > Problems with the response writer/output stream:
> > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> > groovy.lang.MissingPropertyException: No such property: EntityCondition
> for
> > class: ProfileExperiences (No such property: EntityCondition for class:
> > ProfileExperiences)
> >
> > Regards,
> >
> > Pierre
> >
> > 2010/8/23 Pierre Smits <[hidden email]>
> >
> >> Hi Scott,
> >>
> >> Thanks for the pointer. I think it should be on the money.... However
> after
> >> some tweaking I got following error:
> >>
> >> <p>Problems with the response writer&#47;output stream&#58;
> >>
> >> org.ofbiz.widget.screen.ScreenRenderException&#58;
> >> Error rendering screen
> &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
> >>
> >> groovy.lang.MissingPropertyException&#58; No such property&#58;
> >> EntityCondition for class&#58; ProfileExperiences &#40;No such
> property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
> >>
> >> </p>
> >>
> >>
> >> The complete code in the groovy file is:
> >> import org.ofbiz.base.util.*;
> >> import org.ofbiz.entity.*;
> >> import org.ofbiz.entity.util.*;
> >> import org.ofbiz.party.contact.*;
> >> import javolution.util.FastMap;
> >>
> >> List experienceItems = [];
> >>
> >> profileOwnerId = profileSummary.profileOwnerId;
> >> selectedExperiences = parameters.experienceSelected;
> >>
> >>
> >> condList = [];
> >> condList.add(EntityCondition.makeCondition("profileOwnerId",
> >> profileOwnerId));
> >> if (selectedExperiences) {
> >>   condList.add(EntityCondition.makeCondition("experienceId",
> >> EntityOperator.IN, selectedExperiences as List));
> >> }
> >> cond = EntityCondition.makeCondition(condList);
> >> experienceItemList = delegator.findList("ProfileExperience", cond, null,
> >> null, null, false);
> >>
> >> if (experienceItemList) {
> >>    experienceItemList.each { profileExperience ->
> >>        experienceDesc = profileExperience.experienceDesc;
> >>        experienceStartDate = profileExperience.experienceStartDate;
> >>        experienceEndDate = profileExperience.experienceEndDate;
> >>        experienceCustomerId = profileExperience.experienceCustomerId;
> >>        experienceIndustryId = profileExperience.experienceIndustryId;
> >>        experienceProjectId = profileExperience.experienceProjectId;
> >>        experienceTaskId = profileExperience.experienceTaskId;
> >>        experienceBackground = profileExperience.experienceBackground;
> >>        experienceContext = profileExperience.experienceContext;
> >>        experienceTask = profileExperience.experienceTask;
> >>        experienceMethods = profileExperience.experienceMethods;
> >>        experienceTools = profileExperience.experienceTools;
> >>
> >>        Map experienceItemMap = FastMap.newInstance();
> >>        experienceItemMap.putAll((Map) profileExperience);
> >>
> >>        experienceItems.add(experienceItemMap);
> >>    }
> >>    context.experienceItems = experienceItems;
> >>    }
> >>
> >> Any suggestions?
> >>
> >> Regards,
> >>
> >> Pierre
> >>
> >>
> >> 2010/8/21 Scott Gray <[hidden email]>
> >>
> >> Hi Pierre,
> >>>
> >>> See my other response to Michal for the correct code, it was only from
> >>> memory though so may not actually work without tweaking.
> >>>
> >>> Regards
> >>> Scott
> >>>
> >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
> >>>
> >>>> Hi Scott,
> >>>>
> >>>> Thanks for the pointer!
> >>>>
> >>>> Unfortunately, I am a total groovy-newbie....
> >>>>
> >>>> Would
> >>>> selectedExperiences = parameter.selectedExperiences;
> >>>> if (selectedExperiences==""){
> >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
> >>>> [profileOwnerId : profileOwnerId]);
> >>>>   }
> >>>>   else{
> >>>>   experienceItemList = delegator.findList("ProfileExperience",
> >>>> [experienceId : selectedExperiences]);
> >>>>
> >>>>   }
> >>>>
> >>>> do the trick?
> >>>>
> >>>> Regards,
> >>>>
> >>>> Pierre
> >>>>
> >>>>
> >>>> 2010/8/20 Scott Gray <[hidden email]>
> >>>>
> >>>>> Hi Pierre,
> >>>>>
> >>>>> You'll want to use delegator.findList(...) with an EntityOperator.IN
> >>>>> condition for the experience field.
> >>>>>
> >>>>> Regards
> >>>>> Scott
> >>>>>
> >>>>> HotWax Media
> >>>>> http://www.hotwaxmedia.com
> >>>>>
> >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> >>>>>
> >>>>>> In a url I pass following parameters:
> >>>>>>
> >>>>>> ?profile=10000&experience=10000,100010
> >>>>>>
> >>>>>> In a groovy file I get the parameters....
> >>>>>> parameter.profile
> >>>>>> parameter.experience
> >>>>>>
> >>>>>> My question is: how do I get the delegator to find entities in the
> >>>>> database
> >>>>>> based on both parameter.profile and parameter.experience?
> >>>>>>
> >>>>>> In all the other codes in groovy files that I see it seems that
> >>>>> parameters
> >>>>>> have only 1 value... Or I might be overlooking one...
> >>>>>>
> >>>>>> Regards,,
> >>>>>>
> >>>>>> Pierre
> >>>>>
> >>>>>
> >>>
> >>>
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
The same or slightly different?  You also need to do the same for the EntityOperator class and any others that are being used by your script.

Regards
Scott

On 23/08/2010, at 8:47 PM, Pierre Smits wrote:

> Hi Scott,
>
> I added the import. Unfortunately, the result is the same error.
>
> Regards,
>
> Pierre
>
>
> 2010/8/23 Scott Gray <[hidden email]>
> Hi Pierre,
>
> You need to add the EntityCondition class to the list of imports:
> import org.ofbiz.entity.condition.EntityCondition;
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
>
> > The error more readable:
> >
> > Problems with the response writer/output stream:
> > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> > groovy.lang.MissingPropertyException: No such property: EntityCondition for
> > class: ProfileExperiences (No such property: EntityCondition for class:
> > ProfileExperiences)
> >
> > Regards,
> >
> > Pierre
> >
> > 2010/8/23 Pierre Smits <[hidden email]>
> >
> >> Hi Scott,
> >>
> >> Thanks for the pointer. I think it should be on the money.... However after
> >> some tweaking I got following error:
> >>
> >> <p>Problems with the response writer&#47;output stream&#58;
> >>
> >> org.ofbiz.widget.screen.ScreenRenderException&#58;
> >> Error rendering screen &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
> >>
> >> groovy.lang.MissingPropertyException&#58; No such property&#58;
> >> EntityCondition for class&#58; ProfileExperiences &#40;No such property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
> >>
> >> </p>
> >>
> >>
> >> The complete code in the groovy file is:
> >> import org.ofbiz.base.util.*;
> >> import org.ofbiz.entity.*;
> >> import org.ofbiz.entity.util.*;
> >> import org.ofbiz.party.contact.*;
> >> import javolution.util.FastMap;
> >>
> >> List experienceItems = [];
> >>
> >> profileOwnerId = profileSummary.profileOwnerId;
> >> selectedExperiences = parameters.experienceSelected;
> >>
> >>
> >> condList = [];
> >> condList.add(EntityCondition.makeCondition("profileOwnerId",
> >> profileOwnerId));
> >> if (selectedExperiences) {
> >>   condList.add(EntityCondition.makeCondition("experienceId",
> >> EntityOperator.IN, selectedExperiences as List));
> >> }
> >> cond = EntityCondition.makeCondition(condList);
> >> experienceItemList = delegator.findList("ProfileExperience", cond, null,
> >> null, null, false);
> >>
> >> if (experienceItemList) {
> >>    experienceItemList.each { profileExperience ->
> >>        experienceDesc = profileExperience.experienceDesc;
> >>        experienceStartDate = profileExperience.experienceStartDate;
> >>        experienceEndDate = profileExperience.experienceEndDate;
> >>        experienceCustomerId = profileExperience.experienceCustomerId;
> >>        experienceIndustryId = profileExperience.experienceIndustryId;
> >>        experienceProjectId = profileExperience.experienceProjectId;
> >>        experienceTaskId = profileExperience.experienceTaskId;
> >>        experienceBackground = profileExperience.experienceBackground;
> >>        experienceContext = profileExperience.experienceContext;
> >>        experienceTask = profileExperience.experienceTask;
> >>        experienceMethods = profileExperience.experienceMethods;
> >>        experienceTools = profileExperience.experienceTools;
> >>
> >>        Map experienceItemMap = FastMap.newInstance();
> >>        experienceItemMap.putAll((Map) profileExperience);
> >>
> >>        experienceItems.add(experienceItemMap);
> >>    }
> >>    context.experienceItems = experienceItems;
> >>    }
> >>
> >> Any suggestions?
> >>
> >> Regards,
> >>
> >> Pierre
> >>
> >>
> >> 2010/8/21 Scott Gray <[hidden email]>
> >>
> >> Hi Pierre,
> >>>
> >>> See my other response to Michal for the correct code, it was only from
> >>> memory though so may not actually work without tweaking.
> >>>
> >>> Regards
> >>> Scott
> >>>
> >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
> >>>
> >>>> Hi Scott,
> >>>>
> >>>> Thanks for the pointer!
> >>>>
> >>>> Unfortunately, I am a total groovy-newbie....
> >>>>
> >>>> Would
> >>>> selectedExperiences = parameter.selectedExperiences;
> >>>> if (selectedExperiences==""){
> >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
> >>>> [profileOwnerId : profileOwnerId]);
> >>>>   }
> >>>>   else{
> >>>>   experienceItemList = delegator.findList("ProfileExperience",
> >>>> [experienceId : selectedExperiences]);
> >>>>
> >>>>   }
> >>>>
> >>>> do the trick?
> >>>>
> >>>> Regards,
> >>>>
> >>>> Pierre
> >>>>
> >>>>
> >>>> 2010/8/20 Scott Gray <[hidden email]>
> >>>>
> >>>>> Hi Pierre,
> >>>>>
> >>>>> You'll want to use delegator.findList(...) with an EntityOperator.IN
> >>>>> condition for the experience field.
> >>>>>
> >>>>> Regards
> >>>>> Scott
> >>>>>
> >>>>> HotWax Media
> >>>>> http://www.hotwaxmedia.com
> >>>>>
> >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> >>>>>
> >>>>>> In a url I pass following parameters:
> >>>>>>
> >>>>>> ?profile=10000&experience=10000,100010
> >>>>>>
> >>>>>> In a groovy file I get the parameters....
> >>>>>> parameter.profile
> >>>>>> parameter.experience
> >>>>>>
> >>>>>> My question is: how do I get the delegator to find entities in the
> >>>>> database
> >>>>>> based on both parameter.profile and parameter.experience?
> >>>>>>
> >>>>>> In all the other codes in groovy files that I see it seems that
> >>>>> parameters
> >>>>>> have only 1 value... Or I might be overlooking one...
> >>>>>>
> >>>>>> Regards,,
> >>>>>>
> >>>>>> Pierre
> >>>>>
> >>>>>
> >>>
> >>>
> >>
>
>


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

Re: Groovy question regarding passing html parameters

Pierre Smits
You are absolutely right. Slightly the same is a huge difference...

Regards,

Pierre

2010/8/23 Scott Gray <[hidden email]>

> The same or slightly different?  You also need to do the same for the
> EntityOperator class and any others that are being used by your script.
>
> Regards
> Scott
>
> On 23/08/2010, at 8:47 PM, Pierre Smits wrote:
>
> > Hi Scott,
> >
> > I added the import. Unfortunately, the result is the same error.
> >
> > Regards,
> >
> > Pierre
> >
> >
> > 2010/8/23 Scott Gray <[hidden email]>
> > Hi Pierre,
> >
> > You need to add the EntityCondition class to the list of imports:
> > import org.ofbiz.entity.condition.EntityCondition;
> >
> > Regards
> > Scott
> >
> > HotWax Media
> > http://www.hotwaxmedia.com
> >
> > On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
> >
> > > The error more readable:
> > >
> > > Problems with the response writer/output stream:
> > > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > > [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> > > groovy.lang.MissingPropertyException: No such property: EntityCondition
> for
> > > class: ProfileExperiences (No such property: EntityCondition for class:
> > > ProfileExperiences)
> > >
> > > Regards,
> > >
> > > Pierre
> > >
> > > 2010/8/23 Pierre Smits <[hidden email]>
> > >
> > >> Hi Scott,
> > >>
> > >> Thanks for the pointer. I think it should be on the money.... However
> after
> > >> some tweaking I got following error:
> > >>
> > >> <p>Problems with the response writer&#47;output stream&#58;
> > >>
> > >> org.ofbiz.widget.screen.ScreenRenderException&#58;
> > >> Error rendering screen
> &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
> > >>
> > >> groovy.lang.MissingPropertyException&#58; No such property&#58;
> > >> EntityCondition for class&#58; ProfileExperiences &#40;No such
> property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
> > >>
> > >> </p>
> > >>
> > >>
> > >> The complete code in the groovy file is:
> > >> import org.ofbiz.base.util.*;
> > >> import org.ofbiz.entity.*;
> > >> import org.ofbiz.entity.util.*;
> > >> import org.ofbiz.party.contact.*;
> > >> import javolution.util.FastMap;
> > >>
> > >> List experienceItems = [];
> > >>
> > >> profileOwnerId = profileSummary.profileOwnerId;
> > >> selectedExperiences = parameters.experienceSelected;
> > >>
> > >>
> > >> condList = [];
> > >> condList.add(EntityCondition.makeCondition("profileOwnerId",
> > >> profileOwnerId));
> > >> if (selectedExperiences) {
> > >>   condList.add(EntityCondition.makeCondition("experienceId",
> > >> EntityOperator.IN, selectedExperiences as List));
> > >> }
> > >> cond = EntityCondition.makeCondition(condList);
> > >> experienceItemList = delegator.findList("ProfileExperience", cond,
> null,
> > >> null, null, false);
> > >>
> > >> if (experienceItemList) {
> > >>    experienceItemList.each { profileExperience ->
> > >>        experienceDesc = profileExperience.experienceDesc;
> > >>        experienceStartDate = profileExperience.experienceStartDate;
> > >>        experienceEndDate = profileExperience.experienceEndDate;
> > >>        experienceCustomerId = profileExperience.experienceCustomerId;
> > >>        experienceIndustryId = profileExperience.experienceIndustryId;
> > >>        experienceProjectId = profileExperience.experienceProjectId;
> > >>        experienceTaskId = profileExperience.experienceTaskId;
> > >>        experienceBackground = profileExperience.experienceBackground;
> > >>        experienceContext = profileExperience.experienceContext;
> > >>        experienceTask = profileExperience.experienceTask;
> > >>        experienceMethods = profileExperience.experienceMethods;
> > >>        experienceTools = profileExperience.experienceTools;
> > >>
> > >>        Map experienceItemMap = FastMap.newInstance();
> > >>        experienceItemMap.putAll((Map) profileExperience);
> > >>
> > >>        experienceItems.add(experienceItemMap);
> > >>    }
> > >>    context.experienceItems = experienceItems;
> > >>    }
> > >>
> > >> Any suggestions?
> > >>
> > >> Regards,
> > >>
> > >> Pierre
> > >>
> > >>
> > >> 2010/8/21 Scott Gray <[hidden email]>
> > >>
> > >> Hi Pierre,
> > >>>
> > >>> See my other response to Michal for the correct code, it was only
> from
> > >>> memory though so may not actually work without tweaking.
> > >>>
> > >>> Regards
> > >>> Scott
> > >>>
> > >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
> > >>>
> > >>>> Hi Scott,
> > >>>>
> > >>>> Thanks for the pointer!
> > >>>>
> > >>>> Unfortunately, I am a total groovy-newbie....
> > >>>>
> > >>>> Would
> > >>>> selectedExperiences = parameter.selectedExperiences;
> > >>>> if (selectedExperiences==""){
> > >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
> > >>>> [profileOwnerId : profileOwnerId]);
> > >>>>   }
> > >>>>   else{
> > >>>>   experienceItemList = delegator.findList("ProfileExperience",
> > >>>> [experienceId : selectedExperiences]);
> > >>>>
> > >>>>   }
> > >>>>
> > >>>> do the trick?
> > >>>>
> > >>>> Regards,
> > >>>>
> > >>>> Pierre
> > >>>>
> > >>>>
> > >>>> 2010/8/20 Scott Gray <[hidden email]>
> > >>>>
> > >>>>> Hi Pierre,
> > >>>>>
> > >>>>> You'll want to use delegator.findList(...) with an
> EntityOperator.IN
> > >>>>> condition for the experience field.
> > >>>>>
> > >>>>> Regards
> > >>>>> Scott
> > >>>>>
> > >>>>> HotWax Media
> > >>>>> http://www.hotwaxmedia.com
> > >>>>>
> > >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> > >>>>>
> > >>>>>> In a url I pass following parameters:
> > >>>>>>
> > >>>>>> ?profile=10000&experience=10000,100010
> > >>>>>>
> > >>>>>> In a groovy file I get the parameters....
> > >>>>>> parameter.profile
> > >>>>>> parameter.experience
> > >>>>>>
> > >>>>>> My question is: how do I get the delegator to find entities in the
> > >>>>> database
> > >>>>>> based on both parameter.profile and parameter.experience?
> > >>>>>>
> > >>>>>> In all the other codes in groovy files that I see it seems that
> > >>>>> parameters
> > >>>>>> have only 1 value... Or I might be overlooking one...
> > >>>>>>
> > >>>>>> Regards,,
> > >>>>>>
> > >>>>>> Pierre
> > >>>>>
> > >>>>>
> > >>>
> > >>>
> > >>
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Pierre Smits
I have added some print statements to the code to see what is generated, and
I see following in my ofbiz console:

selectedExperiences are 10003, 10020
condList = [profileOwnerId = '10010', experienceId IN ('1', '0', '0', '0',
'3',
',', ' ', '1', '0', '0', '2', '0')]
cond = (profileOwnerId = '10010' AND experienceId IN ('1', '0', '0', '0',
'3', '
,', ' ', '1', '0', '0', '2', '0'))

It seems that the values of the second part of the query_string
(&experienceSelected=10003, 10020) parsed in individual characters in
EntityCondition.makeCondition("experienceId", EntityOperator.IN,
selectedExperiences as List)



2010/8/23 Pierre Smits <[hidden email]>

> You are absolutely right. Slightly the same is a huge difference...
>
>
> Regards,
>
> Pierre
>
> 2010/8/23 Scott Gray <[hidden email]>
>
>> The same or slightly different?  You also need to do the same for the
>> EntityOperator class and any others that are being used by your script.
>>
>> Regards
>> Scott
>>
>> On 23/08/2010, at 8:47 PM, Pierre Smits wrote:
>>
>> > Hi Scott,
>> >
>> > I added the import. Unfortunately, the result is the same error.
>> >
>> > Regards,
>> >
>> > Pierre
>> >
>> >
>> > 2010/8/23 Scott Gray <[hidden email]>
>> > Hi Pierre,
>> >
>> > You need to add the EntityCondition class to the list of imports:
>> > import org.ofbiz.entity.condition.EntityCondition;
>> >
>> > Regards
>> > Scott
>> >
>> > HotWax Media
>> > http://www.hotwaxmedia.com
>> >
>> > On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
>> >
>> > > The error more readable:
>> > >
>> > > Problems with the response writer/output stream:
>> > > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
>> > >
>> [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
>> > > groovy.lang.MissingPropertyException: No such property:
>> EntityCondition for
>> > > class: ProfileExperiences (No such property: EntityCondition for
>> class:
>> > > ProfileExperiences)
>> > >
>> > > Regards,
>> > >
>> > > Pierre
>> > >
>> > > 2010/8/23 Pierre Smits <[hidden email]>
>> > >
>> > >> Hi Scott,
>> > >>
>> > >> Thanks for the pointer. I think it should be on the money.... However
>> after
>> > >> some tweaking I got following error:
>> > >>
>> > >> <p>Problems with the response writer&#47;output stream&#58;
>> > >>
>> > >> org.ofbiz.widget.screen.ScreenRenderException&#58;
>> > >> Error rendering screen
>> &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
>> > >>
>> > >> groovy.lang.MissingPropertyException&#58; No such property&#58;
>> > >> EntityCondition for class&#58; ProfileExperiences &#40;No such
>> property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
>> > >>
>> > >> </p>
>> > >>
>> > >>
>> > >> The complete code in the groovy file is:
>> > >> import org.ofbiz.base.util.*;
>> > >> import org.ofbiz.entity.*;
>> > >> import org.ofbiz.entity.util.*;
>> > >> import org.ofbiz.party.contact.*;
>> > >> import javolution.util.FastMap;
>> > >>
>> > >> List experienceItems = [];
>> > >>
>> > >> profileOwnerId = profileSummary.profileOwnerId;
>> > >> selectedExperiences = parameters.experienceSelected;
>> > >>
>> > >>
>> > >> condList = [];
>> > >> condList.add(EntityCondition.makeCondition("profileOwnerId",
>> > >> profileOwnerId));
>> > >> if (selectedExperiences) {
>> > >>   condList.add(EntityCondition.makeCondition("experienceId",
>> > >> EntityOperator.IN, selectedExperiences as List));
>> > >> }
>> > >> cond = EntityCondition.makeCondition(condList);
>> > >> experienceItemList = delegator.findList("ProfileExperience", cond,
>> null,
>> > >> null, null, false);
>> > >>
>> > >> if (experienceItemList) {
>> > >>    experienceItemList.each { profileExperience ->
>> > >>        experienceDesc = profileExperience.experienceDesc;
>> > >>        experienceStartDate = profileExperience.experienceStartDate;
>> > >>        experienceEndDate = profileExperience.experienceEndDate;
>> > >>        experienceCustomerId = profileExperience.experienceCustomerId;
>> > >>        experienceIndustryId = profileExperience.experienceIndustryId;
>> > >>        experienceProjectId = profileExperience.experienceProjectId;
>> > >>        experienceTaskId = profileExperience.experienceTaskId;
>> > >>        experienceBackground = profileExperience.experienceBackground;
>> > >>        experienceContext = profileExperience.experienceContext;
>> > >>        experienceTask = profileExperience.experienceTask;
>> > >>        experienceMethods = profileExperience.experienceMethods;
>> > >>        experienceTools = profileExperience.experienceTools;
>> > >>
>> > >>        Map experienceItemMap = FastMap.newInstance();
>> > >>        experienceItemMap.putAll((Map) profileExperience);
>> > >>
>> > >>        experienceItems.add(experienceItemMap);
>> > >>    }
>> > >>    context.experienceItems = experienceItems;
>> > >>    }
>> > >>
>> > >> Any suggestions?
>> > >>
>> > >> Regards,
>> > >>
>> > >> Pierre
>> > >>
>> > >>
>> > >> 2010/8/21 Scott Gray <[hidden email]>
>> > >>
>> > >> Hi Pierre,
>> > >>>
>> > >>> See my other response to Michal for the correct code, it was only
>> from
>> > >>> memory though so may not actually work without tweaking.
>> > >>>
>> > >>> Regards
>> > >>> Scott
>> > >>>
>> > >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
>> > >>>
>> > >>>> Hi Scott,
>> > >>>>
>> > >>>> Thanks for the pointer!
>> > >>>>
>> > >>>> Unfortunately, I am a total groovy-newbie....
>> > >>>>
>> > >>>> Would
>> > >>>> selectedExperiences = parameter.selectedExperiences;
>> > >>>> if (selectedExperiences==""){
>> > >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
>> > >>>> [profileOwnerId : profileOwnerId]);
>> > >>>>   }
>> > >>>>   else{
>> > >>>>   experienceItemList = delegator.findList("ProfileExperience",
>> > >>>> [experienceId : selectedExperiences]);
>> > >>>>
>> > >>>>   }
>> > >>>>
>> > >>>> do the trick?
>> > >>>>
>> > >>>> Regards,
>> > >>>>
>> > >>>> Pierre
>> > >>>>
>> > >>>>
>> > >>>> 2010/8/20 Scott Gray <[hidden email]>
>> > >>>>
>> > >>>>> Hi Pierre,
>> > >>>>>
>> > >>>>> You'll want to use delegator.findList(...) with an
>> EntityOperator.IN
>> > >>>>> condition for the experience field.
>> > >>>>>
>> > >>>>> Regards
>> > >>>>> Scott
>> > >>>>>
>> > >>>>> HotWax Media
>> > >>>>> http://www.hotwaxmedia.com
>> > >>>>>
>> > >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>> > >>>>>
>> > >>>>>> In a url I pass following parameters:
>> > >>>>>>
>> > >>>>>> ?profile=10000&experience=10000,100010
>> > >>>>>>
>> > >>>>>> In a groovy file I get the parameters....
>> > >>>>>> parameter.profile
>> > >>>>>> parameter.experience
>> > >>>>>>
>> > >>>>>> My question is: how do I get the delegator to find entities in
>> the
>> > >>>>> database
>> > >>>>>> based on both parameter.profile and parameter.experience?
>> > >>>>>>
>> > >>>>>> In all the other codes in groovy files that I see it seems that
>> > >>>>> parameters
>> > >>>>>> have only 1 value... Or I might be overlooking one...
>> > >>>>>>
>> > >>>>>> Regards,,
>> > >>>>>>
>> > >>>>>> Pierre
>> > >>>>>
>> > >>>>>
>> > >>>
>> > >>>
>> > >>
>> >
>> >
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
Try removing the "as List" in the entity condition (I checked and an array parameter value is automatically converted to a list of values).  If that doesn't work, what do the form inputs for experienceId look like?  You should have multiple input fields (checkboxes I guess) sharing the same experienceId input name.

Regards
Scott

On 23/08/2010, at 10:07 PM, Pierre Smits wrote:

> I have added some print statements to the code to see what is generated, and I see following in my ofbiz console:
>
> selectedExperiences are 10003, 10020
> condList = [profileOwnerId = '10010', experienceId IN ('1', '0', '0', '0', '3',
> ',', ' ', '1', '0', '0', '2', '0')]
> cond = (profileOwnerId = '10010' AND experienceId IN ('1', '0', '0', '0', '3', '
> ,', ' ', '1', '0', '0', '2', '0'))
>
> It seems that the values of the second part of the query_string (&experienceSelected=10003, 10020) parsed in individual characters in
> EntityCondition.makeCondition("experienceId", EntityOperator.IN, selectedExperiences as List)
>
>
>
> 2010/8/23 Pierre Smits <[hidden email]>
> You are absolutely right. Slightly the same is a huge difference...
>
>
> Regards,
>
> Pierre
>
> 2010/8/23 Scott Gray <[hidden email]>
> The same or slightly different?  You also need to do the same for the EntityOperator class and any others that are being used by your script.
>
> Regards
> Scott
>
> On 23/08/2010, at 8:47 PM, Pierre Smits wrote:
>
> > Hi Scott,
> >
> > I added the import. Unfortunately, the result is the same error.
> >
> > Regards,
> >
> > Pierre
> >
> >
> > 2010/8/23 Scott Gray <[hidden email]>
> > Hi Pierre,
> >
> > You need to add the EntityCondition class to the list of imports:
> > import org.ofbiz.entity.condition.EntityCondition;
> >
> > Regards
> > Scott
> >
> > HotWax Media
> > http://www.hotwaxmedia.com
> >
> > On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
> >
> > > The error more readable:
> > >
> > > Problems with the response writer/output stream:
> > > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > > [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> > > groovy.lang.MissingPropertyException: No such property: EntityCondition for
> > > class: ProfileExperiences (No such property: EntityCondition for class:
> > > ProfileExperiences)
> > >
> > > Regards,
> > >
> > > Pierre
> > >
> > > 2010/8/23 Pierre Smits <[hidden email]>
> > >
> > >> Hi Scott,
> > >>
> > >> Thanks for the pointer. I think it should be on the money.... However after
> > >> some tweaking I got following error:
> > >>
> > >> <p>Problems with the response writer&#47;output stream&#58;
> > >>
> > >> org.ofbiz.widget.screen.ScreenRenderException&#58;
> > >> Error rendering screen &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
> > >>
> > >> groovy.lang.MissingPropertyException&#58; No such property&#58;
> > >> EntityCondition for class&#58; ProfileExperiences &#40;No such property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
> > >>
> > >> </p>
> > >>
> > >>
> > >> The complete code in the groovy file is:
> > >> import org.ofbiz.base.util.*;
> > >> import org.ofbiz.entity.*;
> > >> import org.ofbiz.entity.util.*;
> > >> import org.ofbiz.party.contact.*;
> > >> import javolution.util.FastMap;
> > >>
> > >> List experienceItems = [];
> > >>
> > >> profileOwnerId = profileSummary.profileOwnerId;
> > >> selectedExperiences = parameters.experienceSelected;
> > >>
> > >>
> > >> condList = [];
> > >> condList.add(EntityCondition.makeCondition("profileOwnerId",
> > >> profileOwnerId));
> > >> if (selectedExperiences) {
> > >>   condList.add(EntityCondition.makeCondition("experienceId",
> > >> EntityOperator.IN, selectedExperiences as List));
> > >> }
> > >> cond = EntityCondition.makeCondition(condList);
> > >> experienceItemList = delegator.findList("ProfileExperience", cond, null,
> > >> null, null, false);
> > >>
> > >> if (experienceItemList) {
> > >>    experienceItemList.each { profileExperience ->
> > >>        experienceDesc = profileExperience.experienceDesc;
> > >>        experienceStartDate = profileExperience.experienceStartDate;
> > >>        experienceEndDate = profileExperience.experienceEndDate;
> > >>        experienceCustomerId = profileExperience.experienceCustomerId;
> > >>        experienceIndustryId = profileExperience.experienceIndustryId;
> > >>        experienceProjectId = profileExperience.experienceProjectId;
> > >>        experienceTaskId = profileExperience.experienceTaskId;
> > >>        experienceBackground = profileExperience.experienceBackground;
> > >>        experienceContext = profileExperience.experienceContext;
> > >>        experienceTask = profileExperience.experienceTask;
> > >>        experienceMethods = profileExperience.experienceMethods;
> > >>        experienceTools = profileExperience.experienceTools;
> > >>
> > >>        Map experienceItemMap = FastMap.newInstance();
> > >>        experienceItemMap.putAll((Map) profileExperience);
> > >>
> > >>        experienceItems.add(experienceItemMap);
> > >>    }
> > >>    context.experienceItems = experienceItems;
> > >>    }
> > >>
> > >> Any suggestions?
> > >>
> > >> Regards,
> > >>
> > >> Pierre
> > >>
> > >>
> > >> 2010/8/21 Scott Gray <[hidden email]>
> > >>
> > >> Hi Pierre,
> > >>>
> > >>> See my other response to Michal for the correct code, it was only from
> > >>> memory though so may not actually work without tweaking.
> > >>>
> > >>> Regards
> > >>> Scott
> > >>>
> > >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
> > >>>
> > >>>> Hi Scott,
> > >>>>
> > >>>> Thanks for the pointer!
> > >>>>
> > >>>> Unfortunately, I am a total groovy-newbie....
> > >>>>
> > >>>> Would
> > >>>> selectedExperiences = parameter.selectedExperiences;
> > >>>> if (selectedExperiences==""){
> > >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
> > >>>> [profileOwnerId : profileOwnerId]);
> > >>>>   }
> > >>>>   else{
> > >>>>   experienceItemList = delegator.findList("ProfileExperience",
> > >>>> [experienceId : selectedExperiences]);
> > >>>>
> > >>>>   }
> > >>>>
> > >>>> do the trick?
> > >>>>
> > >>>> Regards,
> > >>>>
> > >>>> Pierre
> > >>>>
> > >>>>
> > >>>> 2010/8/20 Scott Gray <[hidden email]>
> > >>>>
> > >>>>> Hi Pierre,
> > >>>>>
> > >>>>> You'll want to use delegator.findList(...) with an EntityOperator.IN
> > >>>>> condition for the experience field.
> > >>>>>
> > >>>>> Regards
> > >>>>> Scott
> > >>>>>
> > >>>>> HotWax Media
> > >>>>> http://www.hotwaxmedia.com
> > >>>>>
> > >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> > >>>>>
> > >>>>>> In a url I pass following parameters:
> > >>>>>>
> > >>>>>> ?profile=10000&experience=10000,100010
> > >>>>>>
> > >>>>>> In a groovy file I get the parameters....
> > >>>>>> parameter.profile
> > >>>>>> parameter.experience
> > >>>>>>
> > >>>>>> My question is: how do I get the delegator to find entities in the
> > >>>>> database
> > >>>>>> based on both parameter.profile and parameter.experience?
> > >>>>>>
> > >>>>>> In all the other codes in groovy files that I see it seems that
> > >>>>> parameters
> > >>>>>> have only 1 value... Or I might be overlooking one...
> > >>>>>>
> > >>>>>> Regards,,
> > >>>>>>
> > >>>>>> Pierre
> > >>>>>
> > >>>>>
> > >>>
> > >>>
> > >>
> >
> >
>
>
>


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

Re: Groovy question regarding passing html parameters

Pierre Smits
Hi Scott,

I think I've got it solved.
First I use:
String delims = "[,]";
String[] experienceTokens = selectedExperiences.split(delims);

to split the query_string to a list. And subsequently I use
condList.add(EntityCondition.makeCondition("experienceId",EntityOperator.IN,
experienceTokens as List));

to add the items in the query string as conditions.

This renders:
cond = (profileOwnerId= '10010, experienceId IN('10010','10003'))

And finally I get my pdf with both experiences.

And if I don't send any experienceId's in the query string I get all
experiences associated with profileOwnerId (which is what I want).:)

Thanks for your patience and help.

Regards,

Pierre

2010/8/23 Pierre Smits <[hidden email]>

> When removing 'as list' from the groovy code, I get following error:
>
> Problems with the response writer/output stream:
> org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> java.lang.ClassCastException: java.lang.String cannot be cast to
> java.util.Collection (java.lang.String cannot be cast to
> java.util.Collection)
>
> In my input form (a combination of two) I indeed use a checkbox solution
> to select the experiences: These checkboxes have the same input name. I then
> use some javascript code to generate the url and open a new window which has
> the query_string: ?profileSummaryId=10091&experienceSelected=10003,10020
>
>
>
>
> 2010/8/23 Scott Gray <[hidden email]>
>
>> Try removing the "as List" in the entity condition (I checked and an array
>> parameter value is automatically converted to a list of values).  If that
>> doesn't work, what do the form inputs for experienceId look like?  You
>> should have multiple input fields (checkboxes I guess) sharing the same
>> experienceId input name.
>>
>> Regards
>> Scott
>>
>> On 23/08/2010, at 10:07 PM, Pierre Smits wrote:
>>
>> > I have added some print statements to the code to see what is generated,
>> and I see following in my ofbiz console:
>> >
>> > selectedExperiences are 10003, 10020
>> > condList = [profileOwnerId = '10010', experienceId IN ('1', '0', '0',
>> '0', '3',
>> > ',', ' ', '1', '0', '0', '2', '0')]
>> > cond = (profileOwnerId = '10010' AND experienceId IN ('1', '0', '0',
>> '0', '3', '
>> > ,', ' ', '1', '0', '0', '2', '0'))
>> >
>> > It seems that the values of the second part of the query_string
>> (&experienceSelected=10003, 10020) parsed in individual characters in
>> > EntityCondition.makeCondition("experienceId", EntityOperator.IN,
>> selectedExperiences as List)
>> >
>> >
>> >
>> > 2010/8/23 Pierre Smits <[hidden email]>
>> > You are absolutely right. Slightly the same is a huge difference...
>> >
>> >
>> > Regards,
>> >
>> > Pierre
>> >
>> > 2010/8/23 Scott Gray <[hidden email]>
>> > The same or slightly different?  You also need to do the same for the
>> EntityOperator class and any others that are being used by your script.
>> >
>> > Regards
>> > Scott
>> >
>> > On 23/08/2010, at 8:47 PM, Pierre Smits wrote:
>> >
>> > > Hi Scott,
>> > >
>> > > I added the import. Unfortunately, the result is the same error.
>> > >
>> > > Regards,
>> > >
>> > > Pierre
>> > >
>> > >
>> > > 2010/8/23 Scott Gray <[hidden email]>
>> > > Hi Pierre,
>> > >
>> > > You need to add the EntityCondition class to the list of imports:
>> > > import org.ofbiz.entity.condition.EntityCondition;
>> > >
>> > > Regards
>> > > Scott
>> > >
>> > > HotWax Media
>> > > http://www.hotwaxmedia.com
>> > >
>> > > On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
>> > >
>> > > > The error more readable:
>> > > >
>> > > > Problems with the response writer/output stream:
>> > > > org.ofbiz.widget.screen.ScreenRenderException: Error rendering
>> screen
>> > > >
>> [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
>> > > > groovy.lang.MissingPropertyException: No such property:
>> EntityCondition for
>> > > > class: ProfileExperiences (No such property: EntityCondition for
>> class:
>> > > > ProfileExperiences)
>> > > >
>> > > > Regards,
>> > > >
>> > > > Pierre
>> > > >
>> > > > 2010/8/23 Pierre Smits <[hidden email]>
>> > > >
>> > > >> Hi Scott,
>> > > >>
>> > > >> Thanks for the pointer. I think it should be on the money....
>> However after
>> > > >> some tweaking I got following error:
>> > > >>
>> > > >> <p>Problems with the response writer&#47;output stream&#58;
>> > > >>
>> > > >> org.ofbiz.widget.screen.ScreenRenderException&#58;
>> > > >> Error rendering screen
>> &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
>> > > >>
>> > > >> groovy.lang.MissingPropertyException&#58; No such property&#58;
>> > > >> EntityCondition for class&#58; ProfileExperiences &#40;No such
>> property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
>> > > >>
>> > > >> </p>
>> > > >>
>> > > >>
>> > > >> The complete code in the groovy file is:
>> > > >> import org.ofbiz.base.util.*;
>> > > >> import org.ofbiz.entity.*;
>> > > >> import org.ofbiz.entity.util.*;
>> > > >> import org.ofbiz.party.contact.*;
>> > > >> import javolution.util.FastMap;
>> > > >>
>> > > >> List experienceItems = [];
>> > > >>
>> > > >> profileOwnerId = profileSummary.profileOwnerId;
>> > > >> selectedExperiences = parameters.experienceSelected;
>> > > >>
>> > > >>
>> > > >> condList = [];
>> > > >> condList.add(EntityCondition.makeCondition("profileOwnerId",
>> > > >> profileOwnerId));
>> > > >> if (selectedExperiences) {
>> > > >>   condList.add(EntityCondition.makeCondition("experienceId",
>> > > >> EntityOperator.IN, selectedExperiences as List));
>> > > >> }
>> > > >> cond = EntityCondition.makeCondition(condList);
>> > > >> experienceItemList = delegator.findList("ProfileExperience", cond,
>> null,
>> > > >> null, null, false);
>> > > >>
>> > > >> if (experienceItemList) {
>> > > >>    experienceItemList.each { profileExperience ->
>> > > >>        experienceDesc = profileExperience.experienceDesc;
>> > > >>        experienceStartDate = profileExperience.experienceStartDate;
>> > > >>        experienceEndDate = profileExperience.experienceEndDate;
>> > > >>        experienceCustomerId =
>> profileExperience.experienceCustomerId;
>> > > >>        experienceIndustryId =
>> profileExperience.experienceIndustryId;
>> > > >>        experienceProjectId = profileExperience.experienceProjectId;
>> > > >>        experienceTaskId = profileExperience.experienceTaskId;
>> > > >>        experienceBackground =
>> profileExperience.experienceBackground;
>> > > >>        experienceContext = profileExperience.experienceContext;
>> > > >>        experienceTask = profileExperience.experienceTask;
>> > > >>        experienceMethods = profileExperience.experienceMethods;
>> > > >>        experienceTools = profileExperience.experienceTools;
>> > > >>
>> > > >>        Map experienceItemMap = FastMap.newInstance();
>> > > >>        experienceItemMap.putAll((Map) profileExperience);
>> > > >>
>> > > >>        experienceItems.add(experienceItemMap);
>> > > >>    }
>> > > >>    context.experienceItems = experienceItems;
>> > > >>    }
>> > > >>
>> > > >> Any suggestions?
>> > > >>
>> > > >> Regards,
>> > > >>
>> > > >> Pierre
>> > > >>
>> > > >>
>> > > >> 2010/8/21 Scott Gray <[hidden email]>
>> > > >>
>> > > >> Hi Pierre,
>> > > >>>
>> > > >>> See my other response to Michal for the correct code, it was only
>> from
>> > > >>> memory though so may not actually work without tweaking.
>> > > >>>
>> > > >>> Regards
>> > > >>> Scott
>> > > >>>
>> > > >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
>> > > >>>
>> > > >>>> Hi Scott,
>> > > >>>>
>> > > >>>> Thanks for the pointer!
>> > > >>>>
>> > > >>>> Unfortunately, I am a total groovy-newbie....
>> > > >>>>
>> > > >>>> Would
>> > > >>>> selectedExperiences = parameter.selectedExperiences;
>> > > >>>> if (selectedExperiences==""){
>> > > >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
>> > > >>>> [profileOwnerId : profileOwnerId]);
>> > > >>>>   }
>> > > >>>>   else{
>> > > >>>>   experienceItemList = delegator.findList("ProfileExperience",
>> > > >>>> [experienceId : selectedExperiences]);
>> > > >>>>
>> > > >>>>   }
>> > > >>>>
>> > > >>>> do the trick?
>> > > >>>>
>> > > >>>> Regards,
>> > > >>>>
>> > > >>>> Pierre
>> > > >>>>
>> > > >>>>
>> > > >>>> 2010/8/20 Scott Gray <[hidden email]>
>> > > >>>>
>> > > >>>>> Hi Pierre,
>> > > >>>>>
>> > > >>>>> You'll want to use delegator.findList(...) with an
>> EntityOperator.IN
>> > > >>>>> condition for the experience field.
>> > > >>>>>
>> > > >>>>> Regards
>> > > >>>>> Scott
>> > > >>>>>
>> > > >>>>> HotWax Media
>> > > >>>>> http://www.hotwaxmedia.com
>> > > >>>>>
>> > > >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
>> > > >>>>>
>> > > >>>>>> In a url I pass following parameters:
>> > > >>>>>>
>> > > >>>>>> ?profile=10000&experience=10000,100010
>> > > >>>>>>
>> > > >>>>>> In a groovy file I get the parameters....
>> > > >>>>>> parameter.profile
>> > > >>>>>> parameter.experience
>> > > >>>>>>
>> > > >>>>>> My question is: how do I get the delegator to find entities in
>> the
>> > > >>>>> database
>> > > >>>>>> based on both parameter.profile and parameter.experience?
>> > > >>>>>>
>> > > >>>>>> In all the other codes in groovy files that I see it seems that
>> > > >>>>> parameters
>> > > >>>>>> have only 1 value... Or I might be overlooking one...
>> > > >>>>>>
>> > > >>>>>> Regards,,
>> > > >>>>>>
>> > > >>>>>> Pierre
>> > > >>>>>
>> > > >>>>>
>> > > >>>
>> > > >>>
>> > > >>
>> > >
>> > >
>> >
>> >
>> >
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Groovy question regarding passing html parameters

Scott Gray-2
Hi Pierre,

I believe the correct way to send multiple values for the same key as part of a query string is like this:
?profileSummaryId=10091&experienceSelected=10003&experienceSelected=10020
That should result in parameters.experienceSelected being a list containing the two values and would avoid you have to split the string yourself.

Regards
Scott

On 24/08/2010, at 12:47 AM, Pierre Smits wrote:

> Hi Scott,
>
> I think I've got it solved.
> First I use:
> String delims = "[,]";
> String[] experienceTokens = selectedExperiences.split(delims);
>
> to split the query_string to a list. And subsequently I use
> condList.add(EntityCondition.makeCondition("experienceId",EntityOperator.IN, experienceTokens as List));
>
> to add the items in the query string as conditions.
>
> This renders:
> cond = (profileOwnerId= '10010, experienceId IN('10010','10003'))
>
> And finally I get my pdf with both experiences.
>
> And if I don't send any experienceId's in the query string I get all experiences associated with profileOwnerId (which is what I want).:)
>
> Thanks for your patience and help.
>
> Regards,
>
> Pierre
>
> 2010/8/23 Pierre Smits <[hidden email]>
> When removing 'as list' from the groovy code, I get following error:
>
> Problems with the response writer/output stream: org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection (java.lang.String cannot be cast to java.util.Collection)
>
> In my input form (a combination of two) I indeed use a checkbox solution  to select the experiences: These checkboxes have the same input name. I then use some javascript code to generate the url and open a new window which has the query_string: ?profileSummaryId=10091&experienceSelected=10003,10020
>
>
>
>
> 2010/8/23 Scott Gray <[hidden email]>
> Try removing the "as List" in the entity condition (I checked and an array parameter value is automatically converted to a list of values).  If that doesn't work, what do the form inputs for experienceId look like?  You should have multiple input fields (checkboxes I guess) sharing the same experienceId input name.
>
> Regards
> Scott
>
> On 23/08/2010, at 10:07 PM, Pierre Smits wrote:
>
> > I have added some print statements to the code to see what is generated, and I see following in my ofbiz console:
> >
> > selectedExperiences are 10003, 10020
> > condList = [profileOwnerId = '10010', experienceId IN ('1', '0', '0', '0', '3',
> > ',', ' ', '1', '0', '0', '2', '0')]
> > cond = (profileOwnerId = '10010' AND experienceId IN ('1', '0', '0', '0', '3', '
> > ,', ' ', '1', '0', '0', '2', '0'))
> >
> > It seems that the values of the second part of the query_string (&experienceSelected=10003, 10020) parsed in individual characters in
> > EntityCondition.makeCondition("experienceId", EntityOperator.IN, selectedExperiences as List)
> >
> >
> >
> > 2010/8/23 Pierre Smits <[hidden email]>
> > You are absolutely right. Slightly the same is a huge difference...
> >
> >
> > Regards,
> >
> > Pierre
> >
> > 2010/8/23 Scott Gray <[hidden email]>
> > The same or slightly different?  You also need to do the same for the EntityOperator class and any others that are being used by your script.
> >
> > Regards
> > Scott
> >
> > On 23/08/2010, at 8:47 PM, Pierre Smits wrote:
> >
> > > Hi Scott,
> > >
> > > I added the import. Unfortunately, the result is the same error.
> > >
> > > Regards,
> > >
> > > Pierre
> > >
> > >
> > > 2010/8/23 Scott Gray <[hidden email]>
> > > Hi Pierre,
> > >
> > > You need to add the EntityCondition class to the list of imports:
> > > import org.ofbiz.entity.condition.EntityCondition;
> > >
> > > Regards
> > > Scott
> > >
> > > HotWax Media
> > > http://www.hotwaxmedia.com
> > >
> > > On 23/08/2010, at 7:49 PM, Pierre Smits wrote:
> > >
> > > > The error more readable:
> > > >
> > > > Problems with the response writer/output stream:
> > > > org.ofbiz.widget.screen.ScreenRenderException: Error rendering screen
> > > > [component://profiler/widget/ProfilerPrintScreens.xml#PrintProfilePDF]:
> > > > groovy.lang.MissingPropertyException: No such property: EntityCondition for
> > > > class: ProfileExperiences (No such property: EntityCondition for class:
> > > > ProfileExperiences)
> > > >
> > > > Regards,
> > > >
> > > > Pierre
> > > >
> > > > 2010/8/23 Pierre Smits <[hidden email]>
> > > >
> > > >> Hi Scott,
> > > >>
> > > >> Thanks for the pointer. I think it should be on the money.... However after
> > > >> some tweaking I got following error:
> > > >>
> > > >> <p>Problems with the response writer&#47;output stream&#58;
> > > >>
> > > >> org.ofbiz.widget.screen.ScreenRenderException&#58;
> > > >> Error rendering screen &#91;component&#58;&#47;&#47;profiler&#47;widget&#47;ProfilerPrintScreens.xml&#35;PrintProfilePDF&#93;&#58;
> > > >>
> > > >> groovy.lang.MissingPropertyException&#58; No such property&#58;
> > > >> EntityCondition for class&#58; ProfileExperiences &#40;No such property&#58; EntityCondition for class&#58; ProfileExperiences&#41;
> > > >>
> > > >> </p>
> > > >>
> > > >>
> > > >> The complete code in the groovy file is:
> > > >> import org.ofbiz.base.util.*;
> > > >> import org.ofbiz.entity.*;
> > > >> import org.ofbiz.entity.util.*;
> > > >> import org.ofbiz.party.contact.*;
> > > >> import javolution.util.FastMap;
> > > >>
> > > >> List experienceItems = [];
> > > >>
> > > >> profileOwnerId = profileSummary.profileOwnerId;
> > > >> selectedExperiences = parameters.experienceSelected;
> > > >>
> > > >>
> > > >> condList = [];
> > > >> condList.add(EntityCondition.makeCondition("profileOwnerId",
> > > >> profileOwnerId));
> > > >> if (selectedExperiences) {
> > > >>   condList.add(EntityCondition.makeCondition("experienceId",
> > > >> EntityOperator.IN, selectedExperiences as List));
> > > >> }
> > > >> cond = EntityCondition.makeCondition(condList);
> > > >> experienceItemList = delegator.findList("ProfileExperience", cond, null,
> > > >> null, null, false);
> > > >>
> > > >> if (experienceItemList) {
> > > >>    experienceItemList.each { profileExperience ->
> > > >>        experienceDesc = profileExperience.experienceDesc;
> > > >>        experienceStartDate = profileExperience.experienceStartDate;
> > > >>        experienceEndDate = profileExperience.experienceEndDate;
> > > >>        experienceCustomerId = profileExperience.experienceCustomerId;
> > > >>        experienceIndustryId = profileExperience.experienceIndustryId;
> > > >>        experienceProjectId = profileExperience.experienceProjectId;
> > > >>        experienceTaskId = profileExperience.experienceTaskId;
> > > >>        experienceBackground = profileExperience.experienceBackground;
> > > >>        experienceContext = profileExperience.experienceContext;
> > > >>        experienceTask = profileExperience.experienceTask;
> > > >>        experienceMethods = profileExperience.experienceMethods;
> > > >>        experienceTools = profileExperience.experienceTools;
> > > >>
> > > >>        Map experienceItemMap = FastMap.newInstance();
> > > >>        experienceItemMap.putAll((Map) profileExperience);
> > > >>
> > > >>        experienceItems.add(experienceItemMap);
> > > >>    }
> > > >>    context.experienceItems = experienceItems;
> > > >>    }
> > > >>
> > > >> Any suggestions?
> > > >>
> > > >> Regards,
> > > >>
> > > >> Pierre
> > > >>
> > > >>
> > > >> 2010/8/21 Scott Gray <[hidden email]>
> > > >>
> > > >> Hi Pierre,
> > > >>>
> > > >>> See my other response to Michal for the correct code, it was only from
> > > >>> memory though so may not actually work without tweaking.
> > > >>>
> > > >>> Regards
> > > >>> Scott
> > > >>>
> > > >>> On 21/08/2010, at 12:02 AM, Pierre Smits wrote:
> > > >>>
> > > >>>> Hi Scott,
> > > >>>>
> > > >>>> Thanks for the pointer!
> > > >>>>
> > > >>>> Unfortunately, I am a total groovy-newbie....
> > > >>>>
> > > >>>> Would
> > > >>>> selectedExperiences = parameter.selectedExperiences;
> > > >>>> if (selectedExperiences==""){
> > > >>>>   experienceItemList = delegator.findByAnd("ProfileExperience",
> > > >>>> [profileOwnerId : profileOwnerId]);
> > > >>>>   }
> > > >>>>   else{
> > > >>>>   experienceItemList = delegator.findList("ProfileExperience",
> > > >>>> [experienceId : selectedExperiences]);
> > > >>>>
> > > >>>>   }
> > > >>>>
> > > >>>> do the trick?
> > > >>>>
> > > >>>> Regards,
> > > >>>>
> > > >>>> Pierre
> > > >>>>
> > > >>>>
> > > >>>> 2010/8/20 Scott Gray <[hidden email]>
> > > >>>>
> > > >>>>> Hi Pierre,
> > > >>>>>
> > > >>>>> You'll want to use delegator.findList(...) with an EntityOperator.IN
> > > >>>>> condition for the experience field.
> > > >>>>>
> > > >>>>> Regards
> > > >>>>> Scott
> > > >>>>>
> > > >>>>> HotWax Media
> > > >>>>> http://www.hotwaxmedia.com
> > > >>>>>
> > > >>>>> On 20/08/2010, at 10:31 PM, Pierre Smits wrote:
> > > >>>>>
> > > >>>>>> In a url I pass following parameters:
> > > >>>>>>
> > > >>>>>> ?profile=10000&experience=10000,100010
> > > >>>>>>
> > > >>>>>> In a groovy file I get the parameters....
> > > >>>>>> parameter.profile
> > > >>>>>> parameter.experience
> > > >>>>>>
> > > >>>>>> My question is: how do I get the delegator to find entities in the
> > > >>>>> database
> > > >>>>>> based on both parameter.profile and parameter.experience?
> > > >>>>>>
> > > >>>>>> In all the other codes in groovy files that I see it seems that
> > > >>>>> parameters
> > > >>>>>> have only 1 value... Or I might be overlooking one...
> > > >>>>>>
> > > >>>>>> Regards,,
> > > >>>>>>
> > > >>>>>> Pierre
> > > >>>>>
> > > >>>>>
> > > >>>
> > > >>>
> > > >>
> > >
> > >
> >
> >
> >
>
>
>


smime.p7s (3K) Download Attachment
12