You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by leonardouit <le...@gmail.com> on 2007/11/30 13:25:46 UTC

defaultNullLabel()

Hi here.

I have a class that extends AjaxEditableLabel. The overriden methods
newEditor and newLabel look as following:

	protected FormComponent newEditor(MarkupContainer parent, String
componentId, IModel model){
		
		RTextField editor =
		(fieldType == null) ? 			
			editor = new RTextField(componentId, model, String.class){
				protected void onComponentTag(ComponentTag tag) {
					super.onComponentTag(tag);
					add(new SimpleAttributeModifier("class", "e0"));
				}
			} :
			new RTextField(componentId, model, fieldType){
				protected void onComponentTag(ComponentTag tag) {
					super.onComponentTag(tag);
					add(new SimpleAttributeModifier("class", "e0"));
			}
		};				
					
		editor.setOutputMarkupId(true);
		editor.setVisible(false);
		editor.add(new EditorAjaxBehavior());
		return editor;
	}
	
	protected Component newLabel(MarkupContainer parent, String componentId,
IModel model){

		RLabel label = new RLabel("label", model)
		{
			private static final long serialVersionUID = 1L;
			
			protected void onComponentTagBody
                        (MarkupStream markupStream, ComponentTag openTag)
			{				
				if (getModelObject() == null) {
					replaceComponentTagBody(markupStream, openTag, defaultNullLabel());
				}
				else
				{
					super.onComponentTagBody(markupStream, openTag);
				}
			}
		};
		label.setOutputMarkupId(true);
		label.add(new LabelAjaxBehavior("onclick"));
		return label;
	}

Note that if the model, on newLabel, is null, then it uses
defaultNullLabel(), which defaults to the "..." string. I believed that I
could override that method to print whatever I wanted to, including the
empty string "". However, if a have something like 

	@Override
	protected String defaultNullLabel() {
		return "" ;
	}

the cell that was meant to be editable, after clicking in and then clicking
out, become NOT EDITABLE!

Any help?
-- 
View this message in context: http://www.nabble.com/defaultNullLabel%28%29-tf4904412.html#a14046749
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: defaultNullLabel()

Posted by Gerolf Seitz <ge...@gmail.com>.
Alex,
this is fixed in current trunk and will be included in 1.3.0-rc2, which
frank might be starting to release this weekend.

Regards,
  Gerolf

On Nov 30, 2007 2:04 PM, Alexander Landsnes Keül <
Alexander.Landsnes.Keul@visma.no> wrote:

> I have something of the same issue, if you have a value of "" in an
> AjaxEditableLabel it's unclickable. It's not removed from the markup, I just
> can't click it. Probably because the Label is 0 pixels wide.
>
> For me the solution was to have "..." if the String was null, and have all
> getters translate "" into null. A pain, but it works.
>
> Alex
>
> -----Opprinnelig melding-----
> Fra: Roy van Rijn [mailto:roy.van.rijn@gmail.com]
> Sendt: 30. november 2007 13:55
> Til: users@wicket.apache.org
> Emne: Re: defaultNullLabel()
>
> It doesn't look like the defaultNullLabel() can cause such a problem..
> Have you tried your code without overwriting the default label?
>
> Also, when you create your RLabel you use the string "label", is this
> on purpose or did you mean to use componentId.
> (the original code has:Label label = new Label(componentId, model))
>
> Roy
>
> On 11/30/07, leonardouit <le...@gmail.com> wrote:
> >
> > Hi here.
> >
> > I have a class that extends AjaxEditableLabel. The overriden methods
> > newEditor and newLabel look as following:
> >
> >        protected FormComponent newEditor(MarkupContainer parent, String
> > componentId, IModel model){
> >
> >                RTextField editor =
> >                (fieldType == null) ?
> >                        editor = new RTextField(componentId, model,
> String.class){
> >                                protected void
> onComponentTag(ComponentTag tag) {
> >                                        super.onComponentTag(tag);
> >                                        add(new
> SimpleAttributeModifier("class", "e0"));
> >                                }
> >                        } :
> >                        new RTextField(componentId, model, fieldType){
> >                                protected void
> onComponentTag(ComponentTag tag) {
> >                                        super.onComponentTag(tag);
> >                                        add(new
> SimpleAttributeModifier("class", "e0"));
> >                        }
> >                };
> >
> >                editor.setOutputMarkupId(true);
> >                editor.setVisible(false);
> >                editor.add(new EditorAjaxBehavior());
> >                return editor;
> >        }
> >
> >        protected Component newLabel(MarkupContainer parent, String
> componentId,
> > IModel model){
> >
> >                RLabel label = new RLabel("label", model)
> >                {
> >                        private static final long serialVersionUID = 1L;
> >
> >                        protected void onComponentTagBody
> >                        (MarkupStream markupStream, ComponentTag openTag)
> >                        {
> >                                if (getModelObject() == null) {
> >
>  replaceComponentTagBody(markupStream, openTag, defaultNullLabel());
> >                                }
> >                                else
> >                                {
> >                                        super.onComponentTagBody(markupStream,
> openTag);
> >                                }
> >                        }
> >                };
> >                label.setOutputMarkupId(true);
> >                label.add(new LabelAjaxBehavior("onclick"));
> >                return label;
> >        }
> >
> > Note that if the model, on newLabel, is null, then it uses
> > defaultNullLabel(), which defaults to the "..." string. I believed that
> I
> > could override that method to print whatever I wanted to, including the
> > empty string "". However, if a have something like
> >
> >        @Override
> >        protected String defaultNullLabel() {
> >                return "" ;
> >        }
> >
> > the cell that was meant to be editable, after clicking in and then
> clicking
> > out, become NOT EDITABLE!
> >
> > Any help?
> > --
> > View this message in context:
> http://www.nabble.com/defaultNullLabel%28%29-tf4904412.html#a14046749
> > 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
>
>

SV: defaultNullLabel()

Posted by Alexander Landsnes Keül <Al...@visma.no>.
I have something of the same issue, if you have a value of "" in an AjaxEditableLabel it's unclickable. It's not removed from the markup, I just can't click it. Probably because the Label is 0 pixels wide.

For me the solution was to have "..." if the String was null, and have all getters translate "" into null. A pain, but it works.

Alex

-----Opprinnelig melding-----
Fra: Roy van Rijn [mailto:roy.van.rijn@gmail.com] 
Sendt: 30. november 2007 13:55
Til: users@wicket.apache.org
Emne: Re: defaultNullLabel()

It doesn't look like the defaultNullLabel() can cause such a problem..
Have you tried your code without overwriting the default label?

Also, when you create your RLabel you use the string "label", is this
on purpose or did you mean to use componentId.
(the original code has:Label label = new Label(componentId, model))

Roy

On 11/30/07, leonardouit <le...@gmail.com> wrote:
>
> Hi here.
>
> I have a class that extends AjaxEditableLabel. The overriden methods
> newEditor and newLabel look as following:
>
>        protected FormComponent newEditor(MarkupContainer parent, String
> componentId, IModel model){
>
>                RTextField editor =
>                (fieldType == null) ?
>                        editor = new RTextField(componentId, model, String.class){
>                                protected void onComponentTag(ComponentTag tag) {
>                                        super.onComponentTag(tag);
>                                        add(new SimpleAttributeModifier("class", "e0"));
>                                }
>                        } :
>                        new RTextField(componentId, model, fieldType){
>                                protected void onComponentTag(ComponentTag tag) {
>                                        super.onComponentTag(tag);
>                                        add(new SimpleAttributeModifier("class", "e0"));
>                        }
>                };
>
>                editor.setOutputMarkupId(true);
>                editor.setVisible(false);
>                editor.add(new EditorAjaxBehavior());
>                return editor;
>        }
>
>        protected Component newLabel(MarkupContainer parent, String componentId,
> IModel model){
>
>                RLabel label = new RLabel("label", model)
>                {
>                        private static final long serialVersionUID = 1L;
>
>                        protected void onComponentTagBody
>                        (MarkupStream markupStream, ComponentTag openTag)
>                        {
>                                if (getModelObject() == null) {
>                                        replaceComponentTagBody(markupStream, openTag, defaultNullLabel());
>                                }
>                                else
>                                {
>                                        super.onComponentTagBody(markupStream, openTag);
>                                }
>                        }
>                };
>                label.setOutputMarkupId(true);
>                label.add(new LabelAjaxBehavior("onclick"));
>                return label;
>        }
>
> Note that if the model, on newLabel, is null, then it uses
> defaultNullLabel(), which defaults to the "..." string. I believed that I
> could override that method to print whatever I wanted to, including the
> empty string "". However, if a have something like
>
>        @Override
>        protected String defaultNullLabel() {
>                return "" ;
>        }
>
> the cell that was meant to be editable, after clicking in and then clicking
> out, become NOT EDITABLE!
>
> Any help?
> --
> View this message in context: http://www.nabble.com/defaultNullLabel%28%29-tf4904412.html#a14046749
> 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: defaultNullLabel()

Posted by Roy van Rijn <ro...@gmail.com>.
It doesn't look like the defaultNullLabel() can cause such a problem..
Have you tried your code without overwriting the default label?

Also, when you create your RLabel you use the string "label", is this
on purpose or did you mean to use componentId.
(the original code has:Label label = new Label(componentId, model))

Roy

On 11/30/07, leonardouit <le...@gmail.com> wrote:
>
> Hi here.
>
> I have a class that extends AjaxEditableLabel. The overriden methods
> newEditor and newLabel look as following:
>
>        protected FormComponent newEditor(MarkupContainer parent, String
> componentId, IModel model){
>
>                RTextField editor =
>                (fieldType == null) ?
>                        editor = new RTextField(componentId, model, String.class){
>                                protected void onComponentTag(ComponentTag tag) {
>                                        super.onComponentTag(tag);
>                                        add(new SimpleAttributeModifier("class", "e0"));
>                                }
>                        } :
>                        new RTextField(componentId, model, fieldType){
>                                protected void onComponentTag(ComponentTag tag) {
>                                        super.onComponentTag(tag);
>                                        add(new SimpleAttributeModifier("class", "e0"));
>                        }
>                };
>
>                editor.setOutputMarkupId(true);
>                editor.setVisible(false);
>                editor.add(new EditorAjaxBehavior());
>                return editor;
>        }
>
>        protected Component newLabel(MarkupContainer parent, String componentId,
> IModel model){
>
>                RLabel label = new RLabel("label", model)
>                {
>                        private static final long serialVersionUID = 1L;
>
>                        protected void onComponentTagBody
>                        (MarkupStream markupStream, ComponentTag openTag)
>                        {
>                                if (getModelObject() == null) {
>                                        replaceComponentTagBody(markupStream, openTag, defaultNullLabel());
>                                }
>                                else
>                                {
>                                        super.onComponentTagBody(markupStream, openTag);
>                                }
>                        }
>                };
>                label.setOutputMarkupId(true);
>                label.add(new LabelAjaxBehavior("onclick"));
>                return label;
>        }
>
> Note that if the model, on newLabel, is null, then it uses
> defaultNullLabel(), which defaults to the "..." string. I believed that I
> could override that method to print whatever I wanted to, including the
> empty string "". However, if a have something like
>
>        @Override
>        protected String defaultNullLabel() {
>                return "" ;
>        }
>
> the cell that was meant to be editable, after clicking in and then clicking
> out, become NOT EDITABLE!
>
> Any help?
> --
> View this message in context: http://www.nabble.com/defaultNullLabel%28%29-tf4904412.html#a14046749
> 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