You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sadiq81 <to...@gmail.com> on 2012/09/25 15:10:04 UTC
Panel use same model as Parent page
How do i get a panel to use the some modelObject as the parent page?
I have a form that uses an OwnedAccount as its model, and in the form i have
a custom panel which has a refreshingview containing a list of
financeAccount which belong to the OwnedAccount. The problem is that changes
to the financeaccounts are not being changed in the modelobject of the form.
I removed a lot of code where there is 3 dots "..."
@Entity
@Table(name = "ownedaccount")
public class OwnedAccount implements Serializable {
...
//used for multiple currencies
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER,
mappedBy = "ownedAccount")
private List<FinanceAccount> financeAccounts = new
ArrayList<FinanceAccount>();
...
}
-------------------------------------
public class AssetsPage extends LoggedInPage {
...
// bookmarkable constructor
public AssetsPage(PageParameters parameters) {
super(parameters);
init();
}
private void init() {
final OwnedAccount ownedAccount =
getCurrentSelections().getSelectedOwnedAccount();
add(new FeedbackPanel("feedback"));
entityEdit = new OwnedAccountForm("entityEdit", ownedAccount);
add(entityEdit);
}
@Override
protected void selectionsChanged() {
OwnedAccount selectedOwnedAccount =
getCurrentSelections().getSelectedOwnedAccount();
CompoundPropertyModel<OwnedAccount> model = new
CompoundPropertyModel<OwnedAccount>(selectedOwnedAccount);
entityEdit.setModel(model);
}
...
class OwnedAccountForm extends BaseCreateEditForm<OwnedAccount,
Void> {
...
public OwnedAccountForm(String s, OwnedAccount entity) {
super(s, entity, null);
assetType = entity.getAssetType();
}
@Override
protected void initComponents(Void initParams) {
...
multipleCurrenciesPanel = new
MultipleCurrenciesPanel("multipleCurrenciesPanel", ownedAccountService,
getCurrentSelections());
add(multipleCurrenciesPanel);
...
}
...
}
-------------------------------------
public class MultipleCurrenciesPanel extends Panel {
OwnedAccountService ownedAccountService;
CurrentSelections currentSelections;
public MultipleCurrenciesPanel(String id, OwnedAccountService
ownedAccountService, CurrentSelections currentSelections) {
super(id);
this.ownedAccountService = ownedAccountService;
this.currentSelections = currentSelections;
init();
}
private void init() {
DepositoryLabel currencyLabel = new
DepositoryLabel("currency", new ResourceModel("currency"));
add(currencyLabel);
DepositoryLabel accountForSecuritasLabel = new
DepositoryLabel("account.for.securitas", new
ResourceModel("account.for.securitas"));
add(accountForSecuritasLabel);
DepositoryLabel accountForCashLabel = new
DepositoryLabel("account.for.cash", new ResourceModel("account.for.cash"));
add(accountForCashLabel);
DepositoryLabel buttonDeleteLabel = new
DepositoryLabel("button.delete", new ResourceModel("button.delete"));
add(buttonDeleteLabel);
CurrenciesView currenciesView = new
CurrenciesView("financeAccounts", ownedAccountService, currentSelections,
this);
add(currenciesView);
setOutputMarkupId(true);
}
}
I used to have the contents of the panel directly within the AssetPage and i
worked there, but this page will quickly become bloated because i need to
add more stuff to it.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Panel-use-same-model-as-Parent-page-tp4652316.html
Sent from the Users forum 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