[xwiki-devs] reading a single property
Hi, Sorry if this question is too basic, but I am not able to find the answer. I am able to read all the properties of an instance of Species.SpeciesClass class in a document with this code: #set($obj = $doc.getObject("Species.SpeciesClass").xWikiClass) #foreach($prop in $obj.properties) *${prop.prettyName}:* $doc.display($prop.getName())<br/> #end But, please, how could I read a single, let's say, Genrus property of this object? Thanks! Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
Hi,
Sorry if this question is too basic, but I am not able to find the answer.
I am able to read all the properties of an instance of Species.SpeciesClass class in a document with this code:
#set($obj = $doc.getObject("Species.SpeciesClass").xWikiClass) #foreach($prop in $obj.properties) *${prop.prettyName}:* $doc.display($prop.getName())<br/> #end
But, please, how could I read a single, let's say, Genrus property of this object?
$obj.Genrus -- supports l10n or key-value properties $obj.getProperty("Genrus").value -- raw value $doc.display("Genrus") -- supports automatic forms (the view/inline switch) and there are others, but these are the most important. By the way, you should use $doc.use($obj) before the foreach... -- Sergiu Dumitriu http://purl.org/net/sergiu/
Sergiu Dumitriu wrote:
$obj.Genrus -- supports l10n or key-value properties
$obj.getProperty("Genrus").value -- raw value
$doc.display("Genrus") -- supports automatic forms (the view/inline switch)
and there are others, but these are the most important.
Thanks Sergiu. As usually, very precise and useful :-)
By the way, you should use $doc.use($obj) before the foreach...
I am seeing some weird thing here. For instance, in an iteration, I get all the documents sticking with a given condition but the last edited. I don't know if this could or could not be related with the use of $doc.use($obj). I guees not, as far as the problem seems to affect to iterations retrieving a number of documents, not the properties in a class. Anyway, please, why must I use $doc.use($obj) and how use it? Apparently, it has no effect on the result of the sample code I've post before. Best regards, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
I am seeing some weird thing here. For instance, in an iteration, I get all the documents sticking with a given condition but the last edited.
Update: it was my error. I've been using a wrong parameter in the search. All items are showing up now. Sorry for the noise.
I don't know if this could or could not be related with the use of $doc.use($obj). I guees not, as far as the problem seems to affect to iterations retrieving a number of documents, not the properties in a class.
Anyway, please, why must I use $doc.use($obj) and how use it? Apparently, it has no effect on the result of the sample code I've post before.
About this doubt, it will be great to get your or others insight, thanks! Cheers, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
participants (2)
-
[Ricardo Rodriguez] Your EPEC Network ICT Team -
Sergiu Dumitriu