You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by taygolf <ta...@gmail.com> on 2008/02/21 17:21:15 UTC
Panels and feedback messages
ok I am wanting to have a custom feedback message for a testfield that is
created in a panel. I know how to do this for a simple textfield in a form
but I am createing these textfields on the fly using nested panels so I
wanted to know how to do this. Right now I am only adding one panel but I
plan on adding several. here is some code:
template.java
Form form = new Form("myform", new CompoundPropertyModel(request)) {
protected void onSubmit() {
setResponsePage(post.class);
};
};
form.setMarkupId("myform");
form.setOutputMarkupId(true);
form.add(new FeedbackPanel("feedback"));
RepeatingView sections=new RepeatingView("Sections");
sections.add(new generalPanel(sections.newChildId()));
//add other sections here
generalPanel.java
//basically this is a section on my template page. I am going to do a query
and get all the info and create //the panel as needed weither I need
textfields or whatever. again only doing on row right now but I will //soon
add many more.
public class generalPanel extends Panel {
public generalPanel(String id) {
super(id);
RepeatingView generalRows=new RepeatingView("generalRows");
generalRows.add(new textFieldPanel(generalRows.newChildId(), "Test 1",
"Test 2"));
//add more rows to the general Panel here
add(generalRows);
}
}
textFieldPanel.java
public class textFieldPanel extends Panel {
public textFieldPanel(String id, String name1, String name2) {
super(id);
TextField t1 = new TextField("textField1");
t1.setRequired(true);
TextField t2 = new TextField("textField2");
t2.setRequired(true);
Now I want a custom message that says something like: name1 is required
instead of textField1 is required because I can have several of these panels
and the user will not know what textField1 is.
I tried setting the properties file for template.properties to:
myform.Sections.generalRows.textField1.Required=Name is required
but that did not work. once I get this simple change working I will look
into setting the label of textField1 and getting the message to print with
that so I can pass name1 to the message but first I would like to get it
working with a simple generic message.
Do I need to set the properties for the panels as well? do I not need to use
.newChildId() for the panel ids so I can know what the id is? Can I get the
id some how?
please help me and I am sorry this is so long but I felt looking at the code
you would understand what I want more.
Thanks
T
--
View this message in context: http://www.nabble.com/Panels-and-feedback-messages-tp15613738p15613738.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: Panels and feedback messages
Posted by Igor Vaynberg <ig...@gmail.com>.
textfield1.setlabel(new model("name1"));
-igor
On Thu, Feb 21, 2008 at 8:21 AM, taygolf <ta...@gmail.com> wrote:
>
> ok I am wanting to have a custom feedback message for a testfield that is
> created in a panel. I know how to do this for a simple textfield in a form
> but I am createing these textfields on the fly using nested panels so I
> wanted to know how to do this. Right now I am only adding one panel but I
> plan on adding several. here is some code:
>
> template.java
> Form form = new Form("myform", new CompoundPropertyModel(request)) {
> protected void onSubmit() {
> setResponsePage(post.class);
> };
> };
> form.setMarkupId("myform");
> form.setOutputMarkupId(true);
> form.add(new FeedbackPanel("feedback"));
> RepeatingView sections=new RepeatingView("Sections");
> sections.add(new generalPanel(sections.newChildId()));
> //add other sections here
>
> generalPanel.java
> //basically this is a section on my template page. I am going to do a query
> and get all the info and create //the panel as needed weither I need
> textfields or whatever. again only doing on row right now but I will //soon
> add many more.
> public class generalPanel extends Panel {
> public generalPanel(String id) {
> super(id);
> RepeatingView generalRows=new RepeatingView("generalRows");
> generalRows.add(new textFieldPanel(generalRows.newChildId(), "Test 1",
> "Test 2"));
> //add more rows to the general Panel here
> add(generalRows);
> }
> }
>
> textFieldPanel.java
> public class textFieldPanel extends Panel {
>
> public textFieldPanel(String id, String name1, String name2) {
> super(id);
>
> TextField t1 = new TextField("textField1");
> t1.setRequired(true);
> TextField t2 = new TextField("textField2");
> t2.setRequired(true);
>
> Now I want a custom message that says something like: name1 is required
> instead of textField1 is required because I can have several of these panels
> and the user will not know what textField1 is.
>
> I tried setting the properties file for template.properties to:
> myform.Sections.generalRows.textField1.Required=Name is required
>
> but that did not work. once I get this simple change working I will look
> into setting the label of textField1 and getting the message to print with
> that so I can pass name1 to the message but first I would like to get it
> working with a simple generic message.
>
> Do I need to set the properties for the panels as well? do I not need to use
> .newChildId() for the panel ids so I can know what the id is? Can I get the
> id some how?
>
> please help me and I am sorry this is so long but I felt looking at the code
> you would understand what I want more.
>
> Thanks
>
> T
> --
> View this message in context: http://www.nabble.com/Panels-and-feedback-messages-tp15613738p15613738.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