小门:是否可以根据面板添加到的页面来显示面板的组件? [英] Wicket: Is it possible to display components of a panel based on page the panel is added to?

查看:75
本文介绍了小门:是否可以根据面板添加到的页面来显示面板的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Wicket还是很陌生,所以如果这很简单,请原谅.我试图寻找示例,但空无一物.

I'm pretty new to Wicket, so please excuse me if this is a simple task. I tried to look for examples but came up empty.

这是场景.可以说我有一个包含25个数据点(名称,地址,地址,电话等)的客户信息面板.我想在网站上的许多不同页面中重复使用此面板.现在,假设我在面板出现的3个不同页面上具有以下条件:

Here's the scenario. Lets say that I have a customer information panel with 25 data points (name, dob, address, phone, etc). I want to reuse this panel in many different pages on a site. Now lets say I have the following criteria on 3 different pages the panel appears on:

  • 第1页-所有字段均可见且可编辑
  • 第2页-可见出生日期,性别,客户名称,但看不到 可编辑的,所有其他字段都是可见且可编辑的
  • 第3页-出生日期和性别不可见,地址可见 并且可编辑,所有其他字段都是可见的,但不可编辑.
  • Page 1 - All fields are visible and editable
  • Page 2 - Date of Birth, Gender, Customer Name are visible but not editable, all other fields are visible and editable
  • Page 3 - Date of Birth and Gender are not visible, Address is visible and editable, all other fields are visible but not editable.

是否可以使用同一面板(以减少代码重复),但可以根据面板加载到的当前页面来控制其组件?

Is there a way to use the same panel (to reduce code duplication), but control its components based on the current page the panel is loaded into?

感谢您的帮助!

推荐答案

我建议不要像这样隐式更改可见性和可编辑性.而是考虑根据组件的构造函数参数或自定义组件上的其他方法来使其显式.

I would suggest against changing the visibility and editability implicitly like this. Instead consider making it explicit based on constructor arguments for the component or additional methods on the custom component.

这篇关于小门:是否可以根据面板添加到的页面来显示面板的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆