java - Create Wicket component embedding a Textfield and its FeedbackPanel -
java - Create Wicket component embedding a Textfield and its FeedbackPanel -
i write code:
java file:
textfield<string> input1 = (textfield<string>) new textfield<>("input1", model.of("")).add(new urlvalidator()); textfield<string> input2 = (textfield<string>) new textfield<>("input2", model.of("")).add(new urlvalidator()); add(new form<>("form").add( new feedbackpanel("feedbackinput1").setfilter(new componentfeedbackmessagefilter(input1)), new feedbackpanel("feedbackinput2").setfilter(new componentfeedbackmessagefilter(input2)), input1, input2 ));
template file:
<form wicket:id="form"> <!-- first --> <div> <wicket:panel wicket:id="feedbackinput1" /> <label for="input1">input 1: <input type="text" wicket:id="input1" id="input1" /> </label> </div> <!-- sec --> <div> <wicket:panel wicket:id="feedbackinput2" /> <label for="input2">input 2: <input type="text" wicket:id="input2" id="input2" /> </label> </div> <div> <button type="submit">submit</button> </div> </form>
to avoid redundancy, create component (eg: textfieldwithfeedback), can utilize this:
java file:
textfield<string> input1 = (textfield<string>) new textfield<>("input1", model.of("")).add(new urlvalidator()); textfield<string> input2 = (textfield<string>) new textfield<>("input2", model.of("")).add(new urlvalidator()); add(new form<>("form").add( new textfieldwithfeedback("input1", "input 1: ", input1), new textfieldwithfeedback("input2", "input 2: ", input2) ));
template file:
<form wicket:id="form"> <!-- first --> <div wicket:id="input1" /> <!-- sec --> <div wicket:id="input2" /> </form>
i want create wicket component able manage textfield , feedbackpanel, how can do?
look class formcomponent. this:
public class feedbacktextfield<t> extends formcomponent<t> { public feedbacktextfield(string id) { this(id, null); } public feedbacktextfield(string id, imodel<t> model) { super(id, model); textfield<t> tf = new textfield<t>("tx"); add(tf); add(new feedbackpanel("fb").setfilter(new componentfeedbackmessagefilter(tf))); } }
formcomponent works panel need add together own html file class also. can add together component form.
form.add(new feedbacktextfield<string>("input1", model.of("")));
java components wicket
Comments
Post a Comment