Re: Label to Uppercase

2008-05-08 Thread ak

Brilliant suggestions ... Thanks Eelco and Jeremy.
In our proj we attach a behavior to TextField/TextArea like this, but tied
to a specifc event as onblur. 

public class ToUpperCaseBehavior extends AbstractBehavior {

public void onComponentTag(Component component, ComponentTag tag){
tag.put(getJsEvent(),this.value = this.value.toUpperCase(););
}

protected String getJsEvent(){
return onblur;
}

}

Thanks for your pointers and hope other fellow wicketers find it useful.
Cheers,
Andy

-- 
View this message in context: 
http://www.nabble.com/Label-to-Uppercase-tp17114635p17126031.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Label to Uppercase

2008-05-07 Thread ak

Hello,

I need your suggestion on, what are the ways I can get Label to print in
Uppercase.
Couple of ways I know are:
1. I can do it with CSS
2. I can make all fields String.toUpperCase()
3. I can seek your advice :)

My code is like:

Label label = new Label(id) { 
@Override
public boolean isVisible() {
return canIReveal();
}

public void onComponentTag(ComponentTag tag){
tag.put(???,this.value = this.value.toUpperCase(););
}
};
form.add(label);


Thanks and Regards,
Andy
-- 
View this message in context: 
http://www.nabble.com/Label-to-Uppercase-tp17114635p17114635.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Label to Uppercase

2008-05-07 Thread Eelco Hillenius
  I need your suggestion on, what are the ways I can get Label to print in
  Uppercase.

Several ways. An easy one:

public class UpperCaseLabel extends Label {

public UpperCaseLabel(String id) {
super(id);
}

public UpperCaseLabel(String id, String label) {
super(id, label);
}

public UpperCaseLabel(String id, IModel model) {
super(id, model);
}

@Override
protected void onComponentTagBody(final MarkupStream markupStream,
final ComponentTag openTag) {
String s = getModelObjectAsString();
replaceComponentTagBody(markupStream, openTag, s != null ?
s.toUpperCase() : null);
}
}

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Label to Uppercase

2008-05-07 Thread Jeremy Thomerson
As Eelco mentioned, there are quite a few ways... I typically use delegation
for this sort of thing with a model that wraps another model. This way it
can be reused for a Label, dropdown, textfield, etc

you could do then:
add(new LabelString(myLabelID, new UpperCaseModel(new
PropertyModel(myObject, myField;

With code like:

import org.apache.wicket.model.IModel;

public class UpperCaseModel implements IModelString {

private static final long serialVersionUID = 1L;

private final IModelString mNestedModel;

public UpperCaseModel(IModelString nestedModel) {
if (nestedModel == null) {
throw new IllegalArgumentException(parameter 'nestedModel' can
not be 'null'.);
}
mNestedModel = nestedModel;
}

public String getObject() {
String obj = mNestedModel.getObject();
return obj == null ? obj : obj.toUpperCase();;
}

public void setObject(String object) {
mNestedModel.setObject(object);
}

public void detach() {
mNestedModel.detach();
}

}

Hope this helps...
Jeremy Thomerson

On Wed, May 7, 2008 at 4:06 PM, Eelco Hillenius [EMAIL PROTECTED]
wrote:

   I need your suggestion on, what are the ways I can get Label to print
 in
   Uppercase.

 Several ways. An easy one:

 public class UpperCaseLabel extends Label {

public UpperCaseLabel(String id) {
super(id);
}

public UpperCaseLabel(String id, String label) {
super(id, label);
}

public UpperCaseLabel(String id, IModel model) {
super(id, model);
}

@Override
protected void onComponentTagBody(final MarkupStream markupStream,
 final ComponentTag openTag) {
String s = getModelObjectAsString();
replaceComponentTagBody(markupStream, openTag, s != null ?
 s.toUpperCase() : null);
}
 }

 Eelco

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Label to Uppercase

2008-05-07 Thread Eelco Hillenius
Yeah, that a more generic solution. You can even use converters. If
you want to get into an argument with Igor that is ;-)

Eelco

On Wed, May 7, 2008 at 2:25 PM, Jeremy Thomerson
[EMAIL PROTECTED] wrote:
 As Eelco mentioned, there are quite a few ways... I typically use delegation
  for this sort of thing with a model that wraps another model. This way it
  can be reused for a Label, dropdown, textfield, etc

  you could do then:
  add(new LabelString(myLabelID, new UpperCaseModel(new
  PropertyModel(myObject, myField;

  With code like:

  import org.apache.wicket.model.IModel;

  public class UpperCaseModel implements IModelString {

 private static final long serialVersionUID = 1L;

 private final IModelString mNestedModel;

 public UpperCaseModel(IModelString nestedModel) {
 if (nestedModel == null) {
 throw new IllegalArgumentException(parameter 'nestedModel' can
  not be 'null'.);
 }
 mNestedModel = nestedModel;
 }

 public String getObject() {
 String obj = mNestedModel.getObject();
 return obj == null ? obj : obj.toUpperCase();;
 }

 public void setObject(String object) {
 mNestedModel.setObject(object);
 }

 public void detach() {
 mNestedModel.detach();
 }

  }

  Hope this helps...
  Jeremy Thomerson

  On Wed, May 7, 2008 at 4:06 PM, Eelco Hillenius [EMAIL PROTECTED]
  wrote:



 I need your suggestion on, what are the ways I can get Label to print
   in
 Uppercase.
  
   Several ways. An easy one:
  
   public class UpperCaseLabel extends Label {
  
  public UpperCaseLabel(String id) {
  super(id);
  }
  
  public UpperCaseLabel(String id, String label) {
  super(id, label);
  }
  
  public UpperCaseLabel(String id, IModel model) {
  super(id, model);
  }
  
  @Override
  protected void onComponentTagBody(final MarkupStream markupStream,
   final ComponentTag openTag) {
  String s = getModelObjectAsString();
  replaceComponentTagBody(markupStream, openTag, s != null ?
   s.toUpperCase() : null);
  }
   }
  
   Eelco
  


  -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Label to Uppercase

2008-05-07 Thread James Carman
When we finally get commons-functor generified, I'm going to create an
IModel implementation that takes a UnaryFunction and wraps another
IModel.  This would probably be a read-only model, though (unless you
supply the UnaryFunction's inverse also I guess).  This would be
reusable so that you can swap in any function you want
(UpperCaseFunction, etc.).  Another option would be to use the Commons
Collections Transformer interface (as soon as it's generified), since
there are probably a lot of existing implementations of those flying
around (we use them a LOT on our project).


On Wed, May 7, 2008 at 6:05 PM, Eelco Hillenius
[EMAIL PROTECTED] wrote:
 Yeah, that a more generic solution. You can even use converters. If
  you want to get into an argument with Igor that is ;-)

  Eelco



  On Wed, May 7, 2008 at 2:25 PM, Jeremy Thomerson
  [EMAIL PROTECTED] wrote:
   As Eelco mentioned, there are quite a few ways... I typically use 
 delegation
for this sort of thing with a model that wraps another model. This way it
can be reused for a Label, dropdown, textfield, etc
  
you could do then:
add(new LabelString(myLabelID, new UpperCaseModel(new
PropertyModel(myObject, myField;
  
With code like:
  
import org.apache.wicket.model.IModel;
  
public class UpperCaseModel implements IModelString {
  
   private static final long serialVersionUID = 1L;
  
   private final IModelString mNestedModel;
  
   public UpperCaseModel(IModelString nestedModel) {
   if (nestedModel == null) {
   throw new IllegalArgumentException(parameter 'nestedModel' can
not be 'null'.);
   }
   mNestedModel = nestedModel;
   }
  
   public String getObject() {
   String obj = mNestedModel.getObject();
   return obj == null ? obj : obj.toUpperCase();;
   }
  
   public void setObject(String object) {
   mNestedModel.setObject(object);
   }
  
   public void detach() {
   mNestedModel.detach();
   }
  
}
  
Hope this helps...
Jeremy Thomerson
  
On Wed, May 7, 2008 at 4:06 PM, Eelco Hillenius [EMAIL PROTECTED]
wrote:
  
  
  
   I need your suggestion on, what are the ways I can get Label to print
 in
   Uppercase.

 Several ways. An easy one:

 public class UpperCaseLabel extends Label {

public UpperCaseLabel(String id) {
super(id);
}

public UpperCaseLabel(String id, String label) {
super(id, label);
}

public UpperCaseLabel(String id, IModel model) {
super(id, model);
}

@Override
protected void onComponentTagBody(final MarkupStream 
 markupStream,
 final ComponentTag openTag) {
String s = getModelObjectAsString();
replaceComponentTagBody(markupStream, openTag, s != null 
 ?
 s.toUpperCase() : null);
}
 }

 Eelco

  
  
-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


  

  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Label to Uppercase

2008-05-07 Thread Eelco Hillenius
 When we finally get commons-functor generified, I'm going to create an
  IModel implementation that takes a UnaryFunction and wraps another
  IModel.

Sounds cool, looking forward to it.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]