Reputation: 157
Hello guys I have a small issue with wicket , I am new in wicket world so please help me :
the markup is need to add title to the input tag which is child to the form
the html is like this :
<div class="arena-record-button">
<form wicket:id="showEditReservationPanelForm">
<input class="arena-input-submit" type="submit" wicket:id="editReservationButton" wicket:message="value:LabelEdit"/>
</form>
</div>
but any change I did in the html in the input tag does not appear when we prees on the button , otherwise i can add this code in the button constroctur and will work before i press the button :
this.add(new AttributeModifier("title", true, new Model("hello12")));
so the problem is after I press the button.
private void addEditReservationComponents(final ReservationDetailsPanel detailsPanel) { Form<?> showEditReservationPanelForm = new Form("showEditReservationPanelForm"); showEditReservationPanelForm.setOutputMarkupId(true); add(showEditReservationPanelForm);
Button editReservationButton;
boolean editReservation = isVisible(CONFIG_SHOW_EDIT_BUTTON) && reservation.isEditable();
if (editReservation) {
ApplicationBase app = (ApplicationBase) getApplication();
DecorationParameters decorationParameters =
new DecorationParameters(getSession().getLocale(), app.getPortalSite().getId(), Sets.newHashSet(decorations));
EditReservationPanel editReservationPanel = new EditReservationPanel(EDIT_RESERVATION_PANEL_ID, decorationParameters, reservation,
detailsPanel);
editReservationPanel.setVisible(false);
add(editReservationPanel);
editReservationButton = new EditReservationButton(this, editReservationPanel, detailsPanel);
} else {
EmptyPanel editReservationPanel = new EmptyPanel(EDIT_RESERVATION_PANEL_ID);
add(editReservationPanel);
editReservationButton = new Button(EDIT_RESERVATION_BUTTON_ID);
editReservationButton.setVisible(false);
}
showEditReservationPanelForm.add(editReservationButton);
}
/**
* Indicates whether a component with the given portlet configuration key should be visible.
*
* @param key the portlet configuration key
* @return <code>true</code> if and only if the portlet configuration for the given key returns <code>true</code>,
* <code>false</code> otherwise
*/
private boolean isVisible(String key) {
SessionBase session = (SessionBase) getSession();
return session.getPortletConfigurationAsBoolean(key);
}
/**
* Returns the configuration parameters for the indexed record panel.
*
* @param entityType the entity type to get the configuration for
* @return the configuration parameters for the indexed record panel
*/
private IndexedRecordPanelConfigParams getIndexedRecordPanelConfigParams(EntityType entityType) {
SessionBase session = (SessionBase) getSession();
IndexedRecordPanelConfigParams configParams = new IndexedRecordPanelConfigParams(session, entityType);
configParams.setDecorations(decorations);
return configParams;
}
/**
* This button provides the possibility to make the {@link EditReservationPanel} visible.
*/
private static class EditReservationButton extends IndicatingAjaxButton {
private static final long serialVersionUID = -8740143889760682177L;
private final ReservationListItemPanel listItemPanel;
private final EditReservationPanel editReservationPanel;
private final ReservationDetailsPanel reservationDetailsPanel;
/**
* Constructs a new {@link EditReservationButton}.
*
* @param listItemPanel the {@link ReservationListItemPanel} to update on submit
* @param editReservationPanel the {@link EditReservationPanel} to make visible on submit
* @param reservationDetailsPanel
*/
private EditReservationButton(ReservationListItemPanel listItemPanel, EditReservationPanel editReservationPanel,
ReservationDetailsPanel reservationDetailsPanel) {
super(EDIT_RESERVATION_BUTTON_ID);
this.listItemPanel = listItemPanel;
this.editReservationPanel = editReservationPanel;
this.reservationDetailsPanel = reservationDetailsPanel;
setOutputMarkupId(true);
setOutputMarkupPlaceholderTag(true);
}
/**
* @see org.apache.wicket.ajax.markup.html.form.AjaxButton#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget,
* org.apache.wicket.markup.html.form.Form)
*/
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
setVisible(false);
this.add(new AttributeModifier("title", true, new Model("hello12")));
editReservationPanel.setVisible(true);
editReservationPanel.setComponentsToMakeVisibleOnSave(this, reservationDetailsPanel);
editReservationPanel.setComponentsToMakeVisibleOnCancel(this, reservationDetailsPanel);
editReservationPanel.setOutputMarkupPlaceholderTag(true);
editReservationPanel.setOutputMarkupId(true);
if (target != null) {
target.addComponent(editReservationPanel);
target.addComponent(listItemPanel);
target.addComponent(this);
}
}
}
}
Upvotes: 0
Views: 535
Reputation: 17533
You need to add TextField to the Form in your Java code.
private void addEditReservationComponents(final ReservationDetailsPanel detailsPanel) {
Form<MyObject> showEditReservationPanelForm = new Form<MyObject>("showEditReservationPanelForm");
showEditReservationPanelForm.setOutputMarkupId(true);
add(showEditReservationPanelForm);
// new stuff starts here
TextField input = new TextField("editReservationButton", someModel);
input.add(AttributeAppender.append("title", Model.of("Some text")));
showEditReservationPanelForm.add(input);
// ...
}
P.S. I've also changed Object
(java.lang.Object ?!) to MyObject
. I doubt you want to use java.lang.Object
as a model object backing your Form.
Upvotes: 0