Using objects from another page

You’ll need to be more specific and show us your code and what you get.

ATM I think the only documented page we have is:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel

You may also want to check out http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization/

Let me know if this help and what part of the doc we should improve.

Hello there!

I am @stefan.platon project mate. i`ll atach

this is the CLASS PAGE where we got some properties. we created some “pages” as well; i think they are like some objects of my created class. Now i am trying to reach those properties from a page i created using this code :

{{velocity}}
## Retrieve the first object (index [0]) among all objects attached to this page and of a certain class 
#set($obj = $doc.getObject('XWiki.ProiectIPModul1v1Class'))

## Retrieve the raw value of the propertty "field1" for this object, provided
## a property called "field1" is actually defined in the class of this object
#set($rawValue = $obj.getProperty('Nume').value)
XWiki.ProiectIPModul1v1Class : Nume= "$rawValue"

## or value displayed (supports l10n or key-value properties)
#set($ValueDisplayed = $obj.Nume)

#set($class = $obj.xWikiClass) ## access the class object representing SomeSpace.SomeClass
## return the property type: String, TextAreaDate, Boolean, ...
$class.get('Nume').classType

{{/velocity}}

if you want and have some time, you can take a look here : 79.112.3.94:8085/xwiki/bin/view/XWiki/ProiectIPModul1v1Class

I think you have a misunderstanding between an xclass and an xobject.

See http://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel

In short you need to add an xobject of your xclass to a wiki page. $doc.getObject will retrieve the xobject from a wiki page but that page needs to have such an xobject…

i have an xobject as well : but i think i am not setting the $doc.getObject parametter right… or idk where i am doing wrong

ok. You can debug by printing the value of the various variable you set with #set. Can you run this and tells us what you get as output:

{{velocity}}
#set($obj = $doc.getObject('XWiki.ProiectIPModul1v1Class'))
aaa $obj
#set($rawValue = $obj.getProperty('Nume').value)
bbb $rawValue
{{/velocity}}

Also on what page are you when you execute this?

for the moment, on a test page. i need to create registration formulars for each new user and the next module( next team job ) must “import” them ( i mean that they need to have acces to the users formulars, so they can get the values from properties ) .
this is the output of the code you told me to test:

And thank you very much for your time and kindess!

ok so that cannot work since $doc points to the current page and your test page probably doesn’t have the xobject…

You can write:

#set($mydoc = $xwiki.getDocument('XWiki.ProiectIPModul1v1Class'))
#set($obj = $mydoc.getObject('XWiki.ProiectIPModul1v1Class'))

So it would be better to remove the xobject from the ProiectIPModul1v1Class page and instead to add it to your test page.

you are right! The idea with the mydoc was great. I prefere to use this instead of creating an specific object on other page.
How can i print, for example, the next object properties values ? I kinda need to fetch in all the class objects…

Our class project its something like a license registration. Each student has already an account. After they log in, they must complete a licence registration formular. That is my module’s( team ) job . Now i`ll have to find out how can i fetch all the class objects and next, how can i create for each user an empty object of my class .

i found out how to fetch all the objects from a specific document :blush: :blush: :blush: :blush:

One note: don’t put too many xobjects in a single page, it slows down page loading and you may hit performance issues if you have too many xobjects. A best practice is to create one page per license registration for ex. See

i have a question : for example, each user will have a created page, or something like that. The page has the class template, i completed the Strings for each property and after clicking Save and View, i can see the page sheet ( all properties completed with values ). But as i saw, this is NOT AN xOBJECT. Basically, we cant fetch for each property of that page, because its not an object. How can i transform it into an object?

i found out this aswell :D.

Is there any solution to fetch in all pages from my class ? I mean, every user will have a page with an object of my class. but how can i fetch in all those pages, so i can basically fetch in all the objects of my class?

Yes, see http://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module#HQueryLanguageExamples

how can i export a class page ? i must export the class i`ve created, so i can improt on the main xwiki server

just export the page containing the class.

i exported as .pdf and its … well… a PDF :smiley:

i should use .xar ?

Why don’t you try it? :slight_smile:

See http://platform.xwiki.org/xwiki/bin/view/Features/Exports

hello again.

I want that a new user ( from user group ) to have a button like " License registration " and redirect him to a Registration page ( witch is an object of my created class ) . How can i do that ? I dont know how can i “prepare” or “give” to a user a page or object from my class…

And then i need to fetch all those objects so i can create “License schedule” .

what’s the relationship with “using objects from another page”? If there’s none please use one topic per… topic :slight_smile: That makes it easier for users to read questions and answers. Thanks