Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
Hi Igor, Check my response to Re: [Wicket-user] I see a lot of questions and talk aboutDropDownChoice and IChoiceRenderer. I have figured it out and thanks for the help. Florian Igor Vaynberg wrote: since you are using a compound property model, and create your ddc with id categories you are trying to access bean.getCategories() property, but i see no such property defined. so why is your form model compound? once again i urge you to read the models wiki page. -igor On 5/18/07, *Florian Hehlen* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Here is the bean... sorry I should have thought to include it: package com.sag.ids.web.data.dto; import com.sag.ids.api.datamodel.java.*; import java.io.*; public class SymbolDto implements Serializable { public String getIdsDocoId() { return theIdsDocoId; } public void setIdsDocoId(String aIdsDocoId) { theIdsDocoId = aIdsDocoId; } public long getIdsSymbolId() { return theIdsSymbolId; } public void setIdsSymbolId(long aIdsSymbolId) { theIdsSymbolId = aIdsSymbolId; } public String getName() { return theName; } public void setName(String aName) { theName = aName; } public String getCategoryName() { return theCategoryName; } public void setCategoryName(String aCategoryName) { theCategoryName = aCategoryName; } public String getCategoryId() { return theCategoryId; } public void setCategoryId(String aCategoryId) { theCategoryId = aCategoryId; } public String getProductTypeName() { return theProductTypeName; } public void setProductTypeName(String aProductTypeName) { theProductTypeName = aProductTypeName; } public String getProductTypeId() { return theProductTypeId; } public void setProductTypeId(String aProductTypeId) { theProductTypeId = aProductTypeId; } public String getUnderlyingTypeName() { return theUnderlyingTypeName; } public void setUnderlyingTypeName(String aUnderlyingTypeName) { theUnderlyingTypeName = aUnderlyingTypeName; } public String getUnderlyingTypeId() { return theUnderlyingTypeId; } public void setUnderlyingTypeId(String aUnderlyingTypeId) { theUnderlyingTypeId = aUnderlyingTypeId; } public String getCurrencyName() { return theCurrencyName; } public void setCurrencyName(String aCurrencyName) { theCurrencyName = aCurrencyName; } public String getCurrencyId() { return theCurrencyId; } public void setCurrencyId(String aCurrencyId) { theCurrencyId = aCurrencyId; } public String getExchangeName() { return theExchangeName; } public void setExchangeName(String aExchangeName) { theExchangeName = aExchangeName; } public String getExchangeId() { return theExchangeId; } public void setExchangeId(String aExchangeId) { theExchangeId = aExchangeId; } public String getDescription() { return theDescription; } public void setDescription(String aDescription) { theDescription = aDescription; } public String getTradingHours() { return theTradingHours; } public void setTradingHours(String aTradingHours) { theTradingHours = aTradingHours; } public String getUrl() { return theUrl; } public void setUrl(String aUrl) { theUrl = aUrl; } public double getMultiplier() { return theMultiplier; } public void setMultiplier(double aMultiplier) { theMultiplier = aMultiplier; } public void setDaoActionError(String aResult) { theDaoActionErrorState = true; theDaoActionError = aResult; } public boolean isDaoActionErrorState() { return theDaoActionErrorState; }
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
Hi, Thanks for the help... It's starting to make more sense to me although still not working. The issue is definitely with the form model. because all my sandbox experiments show me that it all goes to hell when i introduce the model in the form. My form is a a bean wrapped in a CompoundPropertyModel. Maybe you can clarify below your explanation in that context. florian Igor Vaynberg wrote: if you type it it looks like this DDCT(String,IModelT,IModelListT,IChoiceRendererT) the first model is the one that holds the selection, the second is the one that holds a list of available choices. the constructor with a single model: DDCT(String,IModelListT,IChoiceRendererT) is used when you use DDC in combination with a compound property model on the form, in which case the ddc's id is used as a property expression into form's model to determine the selection. there is a great wiki page on models. so try this myForm.add(new DropDownChoice(select,new Model(),new MyChoices(),myRenderer)); this will create a ddc with a null selection. its not practical, because to get the selection you have to call ddc.getmodelobject(), but it will at least get you going before you decide on what model to use. -igor On 5/16/07, *Florian Hehlen* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: hi, I am new to wicket so I am not sure how simple this issue is. I am creating DropDownChoice components. I want to a) build the the Options from a list of Objects (not primitives) and b) want to render the option id and value as an attribute of the object in the list. this definitly works in the following sample code: public class WicketSandbox extends WebPage { public WicketSandbox() { addPageTitle(Development Sandbox); final Form myForm = new Form(form); add(myForm); final ChoiceRenderer myRenderer = new ChoiceRenderer(name, id); myForm.add(new DropDownChoice(select,new MyChoices(),myRenderer)); } } But as soon as I add an IModel to the form it seems that the DropDownChoice looks up the choices in the form's IModel. I have tried to use the other constructors for the DropDownChoice which require an (String id, IModel model, IModel choices, IChoicerenderer renderer) but I can't figure out what is the difference between the 2 IModel objects that have to be provided. If I provide twice a ref to the same object I get a different error: The expression 'id' is neither an index nor is it a method for the list class java.util.ArrayList this is an improvement because it is accessing the right object and retrieving the list of choices but not extracting the the objects from the list as it does when I use (String id, IModel choices, IChoicerenderer renderer). In all cases if I remove the ChoiceRenderer my web page builds and displays but I see object.toString() values in my drop-downs. Any tips or pointers would be greatly appreciated. Florian Hehlen - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net mailto:Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
no, it doesnt really help since we cant see the bean that is inside mySymbol. as far as the example below: see the use of loadabledetachablemodel below. also you are specifying the same model for selection and list of choices, that makes no sense. if whatever bean inside mySymbol model has a categories property, then see my correction below. -igor On 5/18/07, Florian Hehlen [EMAIL PROTECTED] wrote: public class SymbolAddUpdate extends WebPage { public SymbolAddUpdate(PageParameters aParams) { addFeedback(); addPageTitle(Add/Update Symbol); CompoundPropertyModel mySymbol = checkNewOrUpdate(aParams, aParams.getString(theSymbolId)); final Form myForm = new AddUpdateForm(form.symbol, mySymbol); add(myForm); TextField myName = new TextField(name); final ChoiceOptions myOptions = new LoadableDetachableModel() ( load(){ return theDao.findAllCategoriesAsDto()); }} final ChoiceRenderer myRenderer = new ChoiceRenderer(name, id); final CategoryChoices myCategories = new CategoryChoices(); DropDownChoice myCat = new DropDownChoice(categories, myCategories,myRenderer); [...] } I hope this helps. thanks, florian Igor Vaynberg wrote: if you show me the exact code snippet that doesnt work that will give me the necessary context. -igor On 5/17/07, Florian Hehlen [EMAIL PROTECTED] wrote: Hi, Thanks for the help... It's starting to make more sense to me although still not working. The issue is definitely with the form model. because all my sandbox experiments show me that it all goes to hell when i introduce the model in the form. My form is a a bean wrapped in a CompoundPropertyModel. Maybe you can clarify below your explanation in that context. florian Igor Vaynberg wrote: if you type it it looks like this DDCT(String,IModelT,IModelListT,IChoiceRendererT) the first model is the one that holds the selection, the second is the one that holds a list of available choices. the constructor with a single model: DDCT(String,IModelListT,IChoiceRendererT) is used when you use DDC in combination with a compound property model on the form, in which case the ddc's id is used as a property expression into form's model to determine the selection. there is a great wiki page on models. so try this myForm.add(new DropDownChoice(select,new Model(),new MyChoices(),myRenderer)); this will create a ddc with a null selection. its not practical, because to get the selection you have to call ddc.getmodelobject(), but it will at least get you going before you decide on what model to use. -igor On 5/16/07, Florian Hehlen [EMAIL PROTECTED] wrote: hi, I am new to wicket so I am not sure how simple this issue is. I am creating DropDownChoice components. I want to a) build the the Options from a list of Objects (not primitives) and b) want to render the option id and value as an attribute of the object in the list. this definitly works in the following sample code: public class WicketSandbox extends WebPage { public WicketSandbox() { addPageTitle(Development Sandbox); final Form myForm = new Form(form); add(myForm); final ChoiceRenderer myRenderer = new ChoiceRenderer(name, id); myForm.add(new DropDownChoice(select,new MyChoices(),myRenderer)); } } But as soon as I add an IModel to the form it seems that the DropDownChoice looks up the choices in the form's IModel. I have tried to use the other constructors for the DropDownChoice which require an (String id, IModel model, IModel choices, IChoicerenderer renderer) but I can't figure out what is the difference between the 2 IModel objects that have to be provided. If I provide twice a ref to the same object I get a different error: The expression 'id' is neither an index nor is it a method for the list class java.util.ArrayList this is an improvement because it is accessing the right object and retrieving the list of choices but not extracting the the objects from the list as it does when I use (String id, IModel choices, IChoicerenderer renderer). In all cases if I remove the ChoiceRenderer my web page builds and displays but I see object.toString() values in my drop-downs. Any tips or pointers would be greatly appreciated. Florian Hehlen - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user --
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
Here is the bean... sorry I should have thought to include it: package com.sag.ids.web.data.dto; import com.sag.ids.api.datamodel.java.*; import java.io.*; public class SymbolDto implements Serializable { public String getIdsDocoId() { return theIdsDocoId; } public void setIdsDocoId(String aIdsDocoId) { theIdsDocoId = aIdsDocoId; } public long getIdsSymbolId() { return theIdsSymbolId; } public void setIdsSymbolId(long aIdsSymbolId) { theIdsSymbolId = aIdsSymbolId; } public String getName() { return theName; } public void setName(String aName) { theName = aName; } public String getCategoryName() { return theCategoryName; } public void setCategoryName(String aCategoryName) { theCategoryName = aCategoryName; } public String getCategoryId() { return theCategoryId; } public void setCategoryId(String aCategoryId) { theCategoryId = aCategoryId; } public String getProductTypeName() { return theProductTypeName; } public void setProductTypeName(String aProductTypeName) { theProductTypeName = aProductTypeName; } public String getProductTypeId() { return theProductTypeId; } public void setProductTypeId(String aProductTypeId) { theProductTypeId = aProductTypeId; } public String getUnderlyingTypeName() { return theUnderlyingTypeName; } public void setUnderlyingTypeName(String aUnderlyingTypeName) { theUnderlyingTypeName = aUnderlyingTypeName; } public String getUnderlyingTypeId() { return theUnderlyingTypeId; } public void setUnderlyingTypeId(String aUnderlyingTypeId) { theUnderlyingTypeId = aUnderlyingTypeId; } public String getCurrencyName() { return theCurrencyName; } public void setCurrencyName(String aCurrencyName) { theCurrencyName = aCurrencyName; } public String getCurrencyId() { return theCurrencyId; } public void setCurrencyId(String aCurrencyId) { theCurrencyId = aCurrencyId; } public String getExchangeName() { return theExchangeName; } public void setExchangeName(String aExchangeName) { theExchangeName = aExchangeName; } public String getExchangeId() { return theExchangeId; } public void setExchangeId(String aExchangeId) { theExchangeId = aExchangeId; } public String getDescription() { return theDescription; } public void setDescription(String aDescription) { theDescription = aDescription; } public String getTradingHours() { return theTradingHours; } public void setTradingHours(String aTradingHours) { theTradingHours = aTradingHours; } public String getUrl() { return theUrl; } public void setUrl(String aUrl) { theUrl = aUrl; } public double getMultiplier() { return theMultiplier; } public void setMultiplier(double aMultiplier) { theMultiplier = aMultiplier; } public void setDaoActionError(String aResult) { theDaoActionErrorState = true; theDaoActionError = aResult; } public boolean isDaoActionErrorState() { return theDaoActionErrorState; } public String getDaoActionError() { return theDaoActionError; } private long theIdsSymbolId = -1; private String theIdsDocoId; private String theName = NEW SYMBOL; private String theCategoryName = ; private String theCategoryId = ; private String theProductTypeName = ; private String theProductTypeId = ; private String theUnderlyingTypeName = ; private String theUnderlyingTypeId = ; private String theCurrencyName = ; private String theCurrencyId = ; private String theExchangeName = ; private String theExchangeId = ; private String theDescription = ; private String theTradingHours = ; private String theUrl = ; private double theMultiplier = -1; private String theDaoActionError =; private boolean theDaoActionErrorState; } Igor Vaynberg wrote: no, it doesnt really help since we cant see the bean that is inside mySymbol. as far as the example below: see the use of loadabledetachablemodel below. also you are specifying the same model for selection and list of choices, that makes no sense. if whatever bean inside mySymbol model has a categories property, then see my correction below. -igor On 5/18/07, *Florian Hehlen* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: public class SymbolAddUpdate extends WebPage { public SymbolAddUpdate(PageParameters aParams) { addFeedback(); addPageTitle(Add/Update Symbol);
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
since you are using a compound property model, and create your ddc with id categories you are trying to access bean.getCategories() property, but i see no such property defined. so why is your form model compound? once again i urge you to read the models wiki page. -igor On 5/18/07, Florian Hehlen [EMAIL PROTECTED] wrote: Here is the bean... sorry I should have thought to include it: package com.sag.ids.web.data.dto; import com.sag.ids.api.datamodel.java.*; import java.io.*; public class SymbolDto implements Serializable { public String getIdsDocoId() { return theIdsDocoId; } public void setIdsDocoId(String aIdsDocoId) { theIdsDocoId = aIdsDocoId; } public long getIdsSymbolId() { return theIdsSymbolId; } public void setIdsSymbolId(long aIdsSymbolId) { theIdsSymbolId = aIdsSymbolId; } public String getName() { return theName; } public void setName(String aName) { theName = aName; } public String getCategoryName() { return theCategoryName; } public void setCategoryName(String aCategoryName) { theCategoryName = aCategoryName; } public String getCategoryId() { return theCategoryId; } public void setCategoryId(String aCategoryId) { theCategoryId = aCategoryId; } public String getProductTypeName() { return theProductTypeName; } public void setProductTypeName(String aProductTypeName) { theProductTypeName = aProductTypeName; } public String getProductTypeId() { return theProductTypeId; } public void setProductTypeId(String aProductTypeId) { theProductTypeId = aProductTypeId; } public String getUnderlyingTypeName() { return theUnderlyingTypeName; } public void setUnderlyingTypeName(String aUnderlyingTypeName) { theUnderlyingTypeName = aUnderlyingTypeName; } public String getUnderlyingTypeId() { return theUnderlyingTypeId; } public void setUnderlyingTypeId(String aUnderlyingTypeId) { theUnderlyingTypeId = aUnderlyingTypeId; } public String getCurrencyName() { return theCurrencyName; } public void setCurrencyName(String aCurrencyName) { theCurrencyName = aCurrencyName; } public String getCurrencyId() { return theCurrencyId; } public void setCurrencyId(String aCurrencyId) { theCurrencyId = aCurrencyId; } public String getExchangeName() { return theExchangeName; } public void setExchangeName(String aExchangeName) { theExchangeName = aExchangeName; } public String getExchangeId() { return theExchangeId; } public void setExchangeId(String aExchangeId) { theExchangeId = aExchangeId; } public String getDescription() { return theDescription; } public void setDescription(String aDescription) { theDescription = aDescription; } public String getTradingHours() { return theTradingHours; } public void setTradingHours(String aTradingHours) { theTradingHours = aTradingHours; } public String getUrl() { return theUrl; } public void setUrl(String aUrl) { theUrl = aUrl; } public double getMultiplier() { return theMultiplier; } public void setMultiplier(double aMultiplier) { theMultiplier = aMultiplier; } public void setDaoActionError(String aResult) { theDaoActionErrorState = true; theDaoActionError = aResult; } public boolean isDaoActionErrorState() { return theDaoActionErrorState; } public String getDaoActionError() { return theDaoActionError; } private long theIdsSymbolId = -1; private String theIdsDocoId; private String theName = NEW SYMBOL; private String theCategoryName = ; private String theCategoryId = ; private String theProductTypeName = ; private String theProductTypeId = ; private String theUnderlyingTypeName = ; private String theUnderlyingTypeId = ; private String theCurrencyName = ; private String theCurrencyId = ; private String theExchangeName = ; private String theExchangeId = ; private String theDescription = ; private String theTradingHours = ; private String theUrl = ; private double theMultiplier = -1; private String theDaoActionError =; private boolean theDaoActionErrorState; } Igor Vaynberg wrote: no, it doesnt really help since we cant see the bean that is inside mySymbol. as far as the example below: see the use of
[Wicket-user] DropDownChoice with IModel and ChoiceRenderer
hi, I am new to wicket so I am not sure how simple this issue is. I am creating DropDownChoice components. I want to a) build the the Options from a list of Objects (not primitives) and b) want to render the option id and value as an attribute of the object in the list. this definitly works in the following sample code: public class WicketSandbox extends WebPage { public WicketSandbox() { addPageTitle(Development Sandbox); final Form myForm = new Form(form); add(myForm); final ChoiceRenderer myRenderer = new ChoiceRenderer(name, id); myForm.add(new DropDownChoice(select,new MyChoices(),myRenderer)); } } But as soon as I add an IModel to the form it seems that the DropDownChoice looks up the choices in the form's IModel. I have tried to use the other constructors for the DropDownChoice which require an (String id, IModel model, IModel choices, IChoicerenderer renderer) but I can't figure out what is the difference between the 2 IModel objects that have to be provided. If I provide twice a ref to the same object I get a different error: The expression 'id' is neither an index nor is it a method for the list class java.util.ArrayList this is an improvement because it is accessing the right object and retrieving the list of choices but not extracting the the objects from the list as it does when I use (String id, IModel choices, IChoicerenderer renderer). In all cases if I remove the ChoiceRenderer my web page builds and displays but I see object.toString() values in my drop-downs. Any tips or pointers would be greatly appreciated. Florian Hehlen - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
if you type it it looks like this DDCT(String,IModelT,IModelListT,IChoiceRendererT) the first model is the one that holds the selection, the second is the one that holds a list of available choices. the constructor with a single model: DDCT(String,IModelListT,IChoiceRendererT) is used when you use DDC in combination with a compound property model on the form, in which case the ddc's id is used as a property expression into form's model to determine the selection. there is a great wiki page on models. so try this myForm.add(new DropDownChoice(select,new Model(),new MyChoices(),myRenderer)); this will create a ddc with a null selection. its not practical, because to get the selection you have to call ddc.getmodelobject(), but it will at least get you going before you decide on what model to use. -igor On 5/16/07, Florian Hehlen [EMAIL PROTECTED] wrote: hi, I am new to wicket so I am not sure how simple this issue is. I am creating DropDownChoice components. I want to a) build the the Options from a list of Objects (not primitives) and b) want to render the option id and value as an attribute of the object in the list. this definitly works in the following sample code: public class WicketSandbox extends WebPage { public WicketSandbox() { addPageTitle(Development Sandbox); final Form myForm = new Form(form); add(myForm); final ChoiceRenderer myRenderer = new ChoiceRenderer(name, id); myForm.add(new DropDownChoice(select,new MyChoices(),myRenderer)); } } But as soon as I add an IModel to the form it seems that the DropDownChoice looks up the choices in the form's IModel. I have tried to use the other constructors for the DropDownChoice which require an (String id, IModel model, IModel choices, IChoicerenderer renderer) but I can't figure out what is the difference between the 2 IModel objects that have to be provided. If I provide twice a ref to the same object I get a different error: The expression 'id' is neither an index nor is it a method for the list class java.util.ArrayList this is an improvement because it is accessing the right object and retrieving the list of choices but not extracting the the objects from the list as it does when I use (String id, IModel choices, IChoicerenderer renderer). In all cases if I remove the ChoiceRenderer my web page builds and displays but I see object.toString() values in my drop-downs. Any tips or pointers would be greatly appreciated. Florian Hehlen - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] DropDownChoice with IModel and ChoiceRenderer
On Wed, 16 May 2007, Florian Hehlen wrote: (String id, IModel model, IModel choices, IChoicerenderer renderer) but I can't figure out what is the difference between the 2 IModel objects that have to be provided. If I provide twice a ref to the same object I One is the default choice, and the other is the select list. You do have wicket source in your IDE right? It should be more obvious from there. - Timo -- Timo Rantalaiho +358-45-6709709 Reaktor Innovations OyURL: http://www.ri.fi/ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user