Re: [xwiki-users] Dynamic number of fields in Class

2012-10-15 Thread Marius Dumitru Florea
On Sat, Oct 13, 2012 at 4:04 PM, poppakap poppa...@yahoo.com wrote:
 Ok, it appears that there isn't an automagical way to do it.

 I was hoping that I might be missing something simple, but I guess that I
 need to do it in code.

AppWithinMinutes creates a single xclass per application (e.g.
ShoppingCartClass). In your case you need one more xclass (at least)
for the shopping cart item (following Jerome's suggestion). You need
to create this class yourself and modify ShoppingCartSheet to add
support for managing the shopping cart items (as you said below). As a
result your application entries will have one object of type
ShoppingCartClass and one or more objects of type
ShoppingCartItemClass.


 In the ShoppingCartSheet, I added a little bit of velocity script to add in
 the ShoppingCartItem object with a button click post. So in the sheet I will
 have to take care of listing out the page's items, adding and deleting them.

 Is that what you meant? It would be pretty cool if a Field Type had a
 dynamic count to it though, so that if you added a field to a class property
 list, it would take care of itself. That would rock.

The xclass is a descriptor for a set of xobjects. It holds the list of
properties, their names, types, etc. but it doesn't hold any values!
So you can't use the xclass to store data, you have to use xobjects,
which are instances of an xclass. Objects assign values to the
properties defined by the class.

Note that when you edit your AWM application, you can set default
values to the xclass properties but those values are not saved in the
class but in the template, ShoppingCartTemplate, which is a page that
contains an object of type ShoppingCartClass.

Hope this helps,
Marius


 Thanks again, all of you guys are extremely fast to respond, and I really
 appreciate your kindness.



 --
 View this message in context: 
 http://xwiki.475771.n2.nabble.com/Dynamic-number-of-fields-in-Class-tp7581779p7581784.html
 Sent from the XWiki- Users mailing list archive at Nabble.com.
 ___
 users mailing list
 users@xwiki.org
 http://lists.xwiki.org/mailman/listinfo/users
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Dynamic number of fields in Class

2012-10-15 Thread Sergiu Dumitriu

On 10/15/2012 02:11 AM, Marius Dumitru Florea wrote:

On Sat, Oct 13, 2012 at 4:04 PM, poppakap poppa...@yahoo.com wrote:

Ok, it appears that there isn't an automagical way to do it.

I was hoping that I might be missing something simple, but I guess that I
need to do it in code.


AppWithinMinutes creates a single xclass per application (e.g.
ShoppingCartClass). In your case you need one more xclass (at least)
for the shopping cart item (following Jerome's suggestion). You need
to create this class yourself and modify ShoppingCartSheet to add
support for managing the shopping cart items (as you said below). As a
result your application entries will have one object of type
ShoppingCartClass and one or more objects of type
ShoppingCartItemClass.


And to be explicit, that's outside the scope of the AppWithinMinutes 
wizard, which is optimized for simple applications. More complex 
applications, such as yours, need writing some code.




In the ShoppingCartSheet, I added a little bit of velocity script to add in
the ShoppingCartItem object with a button click post. So in the sheet I will
have to take care of listing out the page's items, adding and deleting them.

Is that what you meant? It would be pretty cool if a Field Type had a
dynamic count to it though, so that if you added a field to a class property
list, it would take care of itself. That would rock.


The xclass is a descriptor for a set of xobjects. It holds the list of
properties, their names, types, etc. but it doesn't hold any values!
So you can't use the xclass to store data, you have to use xobjects,
which are instances of an xclass. Objects assign values to the
properties defined by the class.

Note that when you edit your AWM application, you can set default
values to the xclass properties but those values are not saved in the
class but in the template, ShoppingCartTemplate, which is a page that
contains an object of type ShoppingCartClass.

Hope this helps,
Marius



Thanks again, all of you guys are extremely fast to respond, and I really
appreciate your kindness.




--
Sergiu Dumitriu
http://purl.org/net/sergiu/
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Dynamic number of fields in Class

2012-10-13 Thread poppakap
Ok, it appears that there isn't an automagical way to do it. 

I was hoping that I might be missing something simple, but I guess that I
need to do it in code. 

In the ShoppingCartSheet, I added a little bit of velocity script to add in
the ShoppingCartItem object with a button click post. So in the sheet I will
have to take care of listing out the page's items, adding and deleting them. 

Is that what you meant? It would be pretty cool if a Field Type had a
dynamic count to it though, so that if you added a field to a class property
list, it would take care of itself. That would rock. 

Thanks again, all of you guys are extremely fast to respond, and I really
appreciate your kindness. 



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Dynamic-number-of-fields-in-Class-tp7581779p7581784.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Dynamic number of fields in Class

2012-10-12 Thread Jerome Velociter

Hi,

The scenarios you describe are definitely possible to achieve with XWiki.

The way to realize what you want is to have a several objects per item 
type (and not several fields of the same object).


For example, for a shopping cart you would have for each page with a cart :
- An object of class MyApp.Cart
- N number of objects of class MyApp.CartItem

Then adding/removing items in the cart is simply a matter of 
adding/removing cart item objects from the page.


And yes, users list is the right place for this kind of question. The 
dev list concerns the development of the XWiki software itself.


Hope this helps,
Jerome

On 10/12/2012 10:15 PM, poppakap wrote:

This post has NOT been accepted by the mailing list yet.
Hello all, if this has already been answered, please let me know where, I
have searched all over the place!!

I want to have a class that contains a dynamic number of multiple fields.
Think of it like say a shopping cart. You have one ShoppingCart class that
can contain x number of items. When you edit the shopping cart, you can
click add to add another item, or delete to delete an item from the list.

Or maybe another example would be a RecipeClass, in which you would add in
ingredients and stuff. So you would have a SesameChickenRecipe, and it would
contain maybe 1 chicken, 2 tablespoons of salt, 4 bat wings, and so on.

Is it possible, and if so is there any documentation you can point me to, or
a tutorial, or example??
Also, is it appropriate to post this question in the Xwiki-Users forum or
the Xwiki-Dev forum?

Thanks so much in advance!



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Dynamic-number-of-fields-in-Class-tp7581779.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users



--
Peace,
—Jerome

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Dynamic number of fields in Class

2012-10-12 Thread poppakap
Thank you so much. 

I am ALMOST able to understand, sorry for being a newbie here... but

I have an AppWithinMinutes application. There is a 
ShoppingCartHome with a livetable containing multiple ShopptingCarts. The
livetable works great, and allows you to edit a shopping cart in its list.
When you edit a ShoppingCart, you have all of the fields defined in the
ShoppingCartClass, all of which are a fixed quantity of each. 

My ShoppingCart.ShoppingCartClass contains:

 ShoppingCart.ShoppingCartTemplate and a ShoppingCart.ShoppingCart

If I edit the class of ShoppingCart.ShoppingCartClass, I can add in
various Field Types, such as Long text, short text, date picker... etc.
There isn't an option to add in a field type of my ShoppingCartItemClass

If I edit the objects of ShoppingCart.ShoppingCartClass, I can add in
objects such as ClassSheetBinding, DocumentSheetBinding... etc. If I were to
add in a ShoppingCartItem object on this page, I am only allowed to enter a
specific number of them.

I don't see where to add in the option of one-to-many ShoppingCartItem
classes.





--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Dynamic-number-of-fields-in-Class-tp7581779p7581781.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users