[英]Retrieving the value of a Wicket text field when its form is submitted
Inside a ModalWindow
, I have a panel that contains a text field. 在ModalWindow
,我有一个包含文本字段的面板。 How can I use Wicket to retrieve the value of the field when the user submits the form that it is a part of? 用户提交表单所属字段的表单时,如何使用Wicket检索字段的值?
One common way to save form values is to set up a PropertyModel
( Javadoc ) relationship between the form component (in your case, the text field) and some variable in your Java code. 保存表单值的一种常用方法是在表单组件(在您的情况下为文本字段)与Java代码中的某些变量之间建立PropertyModel
( Javadoc )关系。
For example, if you're trying to get the name of a company's CEO, you might use 例如,如果您要获取公司首席执行官的姓名,则可以使用
Company theCompany = new Company();
// ...
add(new TextField("ceoName", new PropertyModel(theCompany, "ceo")));
in your page class, 在您的网页课程中,
<input type="text" wicket:id="ceoName">
in your markup and 在您的标记中
class Company {
String ceo;
// ...
elsewhere. 别处。
If you provide more information about what you're trying to do, I and others might be able to provide more specific/helpful answers. 如果您提供有关您要做什么的更多信息,我和其他人也许可以提供更具体/有用的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.