[英]How do I make a Wicket Panel hidden?
因此,我必須編輯一位同事的代碼,但似乎無法弄清楚如何進行調整,因此在沒有數據的情況下隱藏面板。 當前,如果沒有數據,則返回null。 如果有客戶可用的信息,它將顯示其完整信息。 如果沒有,我想隱藏面板。 這也是整個站點使用的可重復使用的面板。 我需要進行哪些調整才能使其正常工作?
@Override
protected void onInitialize()
{
// TODO Auto-generated method stub
super.onInitialize();
if(customer != null)
{
loadWithCustomer();
}
else
{
loadWithNoCustomer();
}
}
@Override
protected void onBeforeRender()
{
super.onBeforeRender();
AjaxLink<Void> createOrderLink = makeCreateOrderLink(customer);
SkinnyBuSession session = (SkinnyBuSession) Session.get();
if(session != null && session.getCustomer() == null)
createOrderLink.setEnabled(false);
addOrReplace(createOrderLink);
}
private void loadWithCustomer()
{
addOrReplace(new Label("heading", customer.getAccountName()));
Contact contact = null;
if( customer.getContacts() != null && customer.getContacts().size() > 0)
{
contact = customer.getContacts().get(0);
}
else
{
contact = new Contact();//makeUpJunkContactForNow();
customer.getContacts().add(contact);
}
Address address = null;
if( customer.getAddresses() != null && customer.getAddresses().size() > 0)
{
address = customer.getAddresses().get(0);
}
else
{
address = new Address();//makeUpJunkAddressForNow();
customer.getAddresses().add(address);
}
String phone = contact.getPhoneNumber() != null ? contact.getPhoneNumber().getNationalNumber() : "";
if (phone != null && phone.length() == 10)
{
phone = String.format("(%s) %s-%s", phone.substring(0, 3), phone.substring(3, 6),phone.substring(6, 10));
}
addOrReplace(new Label("accountName", customer.getAccountName()));
addOrReplace(new Label("address1", address.getAddressLine1()));
addOrReplace(new Label("address2", address.getAddressLine2()));
addOrReplace(new Label("city", address.getCityName() + ","));
addOrReplace(new Label("state", address.getStateCode()));
addOrReplace(new Label("postalCode", address.getPostalCode()));
addOrReplace(new Label("contactName", contact.getName()));
addOrReplace(new Label("email", contact.getEmailAddress()));
addOrReplace(new Label("phone", phone));
}
private void loadWithNoCustomer()
{
Label heading = new Label("heading", "");
addOrReplace(heading.setVisible(false));
addOrReplace(new Label("accountName", "").setVisible(false));
addOrReplace(new Label("address1", "").setVisible(false));
addOrReplace(new Label("address2", "").setVisible(false));
addOrReplace(new Label("city", "").setVisible(false));
addOrReplace(new Label("state", "").setVisible(false));
addOrReplace(new Label("postalCode", "").setVisible(false));
addOrReplace(new Label("contactName", "").setVisible(false));
addOrReplace(new Label("email", "").setVisible(false));
addOrReplace(new Label("phone", "").setVisible(false));
}
覆蓋onConfigure,您可能可以執行以下操作:
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(customer != null);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.