Hi All,
I'm a little stumped here, and would like anyone's input to see what I am
doing wrong. I've created a new component that extends FormComponentPanel.
It contains a TextField component. When my form is submitted back to the
server, my model is not updated. :-(
However, when I don't use this component, and I use a standard TextField
component my model is updated when my form is submitted back to the server.
I'm passing the model for my component into the TextField in my component,
so I'm not sure why it doesn't link back up on post back.
Here is my component (any comments on what I am doing wrong would be greatly
appreciated):
public class TextFieldPlaceHolder extends FormComponentPanel<String>{
private TextField<String> txtInput;
public TextFieldPlaceHolder(String id, IModel<String> model, String
placeHolderText) throws Exception{
this(id,model,placeHolderText,false);
}
public TextFieldPlaceHolder(String id, IModel<String> model, String
placeHolderText, boolean isRequired) throws Exception {
super(id, model);
try{
this.setType(String.class);
txtInput = new TextField<String>("txtInput",model){
private static final long serialVersionUID = 1L;
protected void onComponentTag(ComponentTag tag){
super.onComponentTag(tag);
HashMap<String,String> myAttrs =
TextFieldPlaceHolder.this.setOnComponentTagTextField();
if(myAttrs != null){
for(Map.Entry<String, String>
entry : myAttrs.entrySet()){
String key =
entry.getKey();
String value =
entry.getValue();
String attrValue =
tag.getAttribute(key);
if(attrValue == null ||
attrValue.equals("")){
tag.put(key,
value);
}else{
tag.put(key,
attrValue+" "+value);
}
}
}
String okKeyUpFunctionText =
"if(this.value !=
''){$j('#lbl_"+this.getMarkupId()+"').hide();}else{$j('#lbl_"+this.getMarkupId()+"').show();}";
tag.put("onkeyup",okKeyUpFunctionText);
}
};
txtInput.setOutputMarkupPlaceholderTag(true);
txtInput.setLabel(new
DetachableStringModel(placeHolderText));
FormComponentLabel lblLabel = new
FormComponentLabel("lblLabel",txtInput){
private static final long serialVersionUID = 1L;
@SuppressWarnings("rawtypes")
protected void onComponentTag(ComponentTag tag){
super.onComponentTag(tag);
TextField txtInput = (TextField)
TextFieldPlaceHolder.this.get("txtInput");
tag.put("id","lbl_"+txtInput.getMarkupId());
}
};
Label lblText = new
Label("lblText",txtInput.getLabel());
lblText.setRenderBodyOnly(true);
lblLabel.add(lblText);
add(new
RequiredFieldIndicator("reqFldInd",isRequired).setOutputMarkupPlaceholderTag(true));
add(lblLabel);
add(txtInput);
}catch(Exception e){
throw e;
}
}
Thanks! Matt
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Model-Binding-Issue-tp4652337.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]