Discussion:
Casting a return value to a required domain model type
mkavanagh
2014-06-04 14:31:53 UTC
Permalink
Hi,

How do I cast a value that is returned from a taglib which contains a number
of instances of domain model PublishedShr.

I have tried using the 'as' construct in different places without success so
far.

Here is an example:

def pubMkLstP = [] as PublishedShr[]
pubMkLstP= getPubVidList(visitorOrgan: currOrganId)

Were pubMkLstP is a list of instances of the domain type PublishedShr.

The PublishedShr domain model has it own constructor.


-mike



--
View this message in context: http://grails.1312388.n4.nabble.com/Casting-a-return-value-to-a-required-domain-model-type-tp4657072.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Jeff Scott Brown
2014-06-05 05:02:28 UTC
Permalink
Post by mkavanagh
Hi,
How do I cast a value that is returned from a taglib which contains a number
of instances of domain model PublishedShr.
I have tried using the 'as' construct in different places without success so
far.
def pubMkLstP = [] as PublishedShr[]
pubMkLstP= getPubVidList(visitorOrgan: currOrganId)
Were pubMkLstP is a list of instances of the domain type PublishedShr.
The PublishedShr domain model has it own constructor.
-mike
 
I do not understand the question.  The code you showed there does not contain any casts.  The 2 lines of code you show don’t really make sense because you are creating an empty ArrayList, then immediately turning that into an empty array of PublishedShr and then immediately getting rid of that and replacing it with whatever is returned from your getPubVidList method.  It also does not make sense to have a tag lib returning a number of instances of a domain class.

You are probably going to have to show some more context in order to better express what you are trying to do.  Also, this sort of question is better suited for StackOverflow than the mailing list.




JSB


Jeff Scott Brown
***@gopivotal.com

Find The Cause ~ Find The Cure
http://www.autismspeaks.org/



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
mkavanagh
2014-06-05 12:34:29 UTC
Permalink
Hi Jeff,

I will take up your advice and submit this question on Stackoverflow
instead.

I've used this grails-user Nabble forum in the past and found it invaluable.

What is the current criteria for suitable question to be posted here?


-mike





--
View this message in context: http://grails.1312388.n4.nabble.com/Casting-a-return-value-to-a-required-domain-model-type-tp4657072p4657076.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Jeff Scott Brown
2014-06-05 13:32:30 UTC
Permalink
Post by mkavanagh
 
What is the current criteria for suitable question to be posted here?
 
See http://grails.1312388.n4.nabble.com/Deprecating-The-Grails-Mailing-Lists-td4656735.html.



JSB


Jeff Scott Brown
***@gopivotal.com

Find The Cause ~ Find The Cure
http://www.autismspeaks.org/



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
mkavanagh
2014-06-13 13:21:03 UTC
Permalink
Hi Jeff,

thanks for this information.

I hope that the Nabble forum is not going to be removed as I find it an
invaluable tool for helping me with problems and issues.


-mike



--
View this message in context: http://grails.1312388.n4.nabble.com/Casting-a-return-value-to-a-required-domain-model-type-tp4657072p4657112.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...