You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Mathias P.W Nilsson" <ma...@snyltarna.se> on 2009/02/12 12:09:06 UTC
Model on Select
Hi,
I'm using CompoundPropertyModel on a form. When using with SelectOption I
can't set the selected index.
The "none" select option is there to add a none to the list. How can I set
the selected option in the listview? Any Pointers?
materialCategoryInformation = new Select("materialCategoryInformation" );
materialCategoryInformation.add(new SelectOption("none", new
Model(/*NULL*/)));
materialCategoryInformation.setRequired(true);
materialCategoryInformation.setOutputMarkupId( true );
ListView materialCategoryList = new ListView( "materialCategoryList"
, materialCategoryModel ){
private static final long serialVersionUID = 1L;
@Override
protected void populateItem( final ListItem item ){
item.setRenderBodyOnly( true );
final CodedChainInformation codedInformation =
(CodedChainInformation) item.getModelObject();
SelectOption option = new SelectOption( "option" , new Model(
(Serializable) item.getModelObject() )){
private static final long serialVersionUID = 1L;
@Override
protected void onComponentTagBody( MarkupStream markupStream,
ComponentTag tag ){
String name = codedInformation.getName();
if( ! codedInformation.isSeparator() )
name = " " + name;
replaceComponentTagBody(markupStream, tag, name );
}
};
item.add( option );
if( codedInformation.isSeparator() ){
option.add( new SimpleAttributeModifier( "class" , "separator"
));
}else{
option.add( new SimpleAttributeModifier( "class" , "sub" ) );
}
}
};
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21973981.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
How is this possible.
The first time my web container is loaded and I access the page all
dropdowns and Select are set according to the values that my class has( new
CompoundPropertyModel( new Model( myClass ) ) ). When returning to this page
a second time the Select is not set. I have tried all that I can come up
with.
Any pointers?
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21981372.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
Odd, the first time ever I access the page the select option is set otherwise
it is not.
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21975007.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by Igor Vaynberg <ig...@gmail.com>.
oh oh they are on to us!
-igor
On Fri, Feb 13, 2009 at 2:00 PM, Martin Voigt
<ma...@artnology.com> wrote:
> This is the reason they *always* want a quickstart ;)
>
> 2009/2/13 Mathias P.W Nilsson <ma...@snyltarna.se>:
>>
>> Hi again,
>>
>> I created a small project with wicket extension and here it worked fine,
>> even if I used setReuseItems( false ).
>>
>> So the problem must be in my code somewere.
>> --
>> View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22002751.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by Martin Voigt <ma...@artnology.com>.
This is the reason they *always* want a quickstart ;)
2009/2/13 Mathias P.W Nilsson <ma...@snyltarna.se>:
>
> Hi again,
>
> I created a small project with wicket extension and here it worked fine,
> even if I used setReuseItems( false ).
>
> So the problem must be in my code somewere.
> --
> View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22002751.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
Hi again,
I created a small project with wicket extension and here it worked fine,
even if I used setReuseItems( false ).
So the problem must be in my code somewere.
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22002751.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by Igor Vaynberg <ig...@gmail.com>.
use the quickstart maven2 archetype to generate a basic project. add
code to it that replicates your problem. zip it up and attach it to a
jira issue.
-igor
On Fri, Feb 13, 2009 at 10:05 AM, Mathias P.W Nilsson
<ma...@snyltarna.se> wrote:
>
> OK,
>
> How does that work. Do I extract vital parts or do I make an small test
> project?
> --
> View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22001847.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
OK,
How does that work. Do I extract vital parts or do I make an small test
project?
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22001847.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by Igor Vaynberg <ig...@gmail.com>.
then you are more then welcome to provide a quickstart attached to a jira issue.
-igor
On Fri, Feb 13, 2009 at 9:50 AM, Mathias P.W Nilsson
<ma...@snyltarna.se> wrote:
>
> That may be the case but I have already tried that and it does not solve my
> problem.
> --
> View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22001539.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
Thanks anyway for your time, but I think I will stick to DropDownChoice for
now.
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22001718.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
That may be the case but I have already tried that and it does not solve my
problem.
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p22001539.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by Igor Vaynberg <ig...@gmail.com>.
whenever a listview contains form components you have to call
setreuseitems(true).
its in the javadoc, it has been mentioned on this list a thousand times.
its probably on the wiki page somewhere.
-igor
On Thu, Feb 12, 2009 at 3:09 AM, Mathias P.W Nilsson
<ma...@snyltarna.se> wrote:
>
> Hi,
>
> I'm using CompoundPropertyModel on a form. When using with SelectOption I
> can't set the selected index.
> The "none" select option is there to add a none to the list. How can I set
> the selected option in the listview? Any Pointers?
>
> materialCategoryInformation = new Select("materialCategoryInformation" );
> materialCategoryInformation.add(new SelectOption("none", new
> Model(/*NULL*/)));
> materialCategoryInformation.setRequired(true);
> materialCategoryInformation.setOutputMarkupId( true );
>
> ListView materialCategoryList = new ListView( "materialCategoryList"
> , materialCategoryModel ){
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem( final ListItem item ){
> item.setRenderBodyOnly( true );
> final CodedChainInformation codedInformation =
> (CodedChainInformation) item.getModelObject();
>
> SelectOption option = new SelectOption( "option" , new Model(
> (Serializable) item.getModelObject() )){
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void onComponentTagBody( MarkupStream markupStream,
> ComponentTag tag ){
> String name = codedInformation.getName();
> if( ! codedInformation.isSeparator() )
> name = " " + name;
> replaceComponentTagBody(markupStream, tag, name );
>
> }
> };
>
> item.add( option );
>
> if( codedInformation.isSeparator() ){
> option.add( new SimpleAttributeModifier( "class" , "separator"
> ));
> }else{
> option.add( new SimpleAttributeModifier( "class" , "sub" ) );
> }
>
>
> }
> };
> --
> View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21973981.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by jn73 <jn...@gmail.com>.
Mathias P.W Nilsson wrote:
>
> The first time my web container is loaded and I access the page all
> dropdowns and Select are set according to the values that my class has(
> new CompoundPropertyModel( new Model( myClass ) ) ). When returning to
> this page a second time the Select is not set. I have tried all that I can
> come up with.
>
I have a similar problem with the Select component. Everything works as
expected until there is a validation error on the form submit. If this
happens the Select components will display a None value in my case, so i
have to re-select items again.
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21996211.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Model on Select
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
After switching from Select and SelectOption to DropDownChoice it works.
Maybe there is a problem with my Select code or there is a wicket bug.
// Mathias
--
View this message in context: http://www.nabble.com/Model-on-Select-tp21973981p21994805.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org