You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2014/03/18 19:36:55 UTC
Expandable section in ListView
I have a list view that will have a button on the left to expand or contract
a section that starts out hidden. this section will have some additional
details. Code and HTML below.
When I click the button, the event arrives in my onActivityLogExpansion, and
the wicket ajax debug control turns red. The log says the following, that I
did not setOutputMarkupdId to true. But I did as you can see in the code.
INFO: focus set on ui-id-3
INFO: focus removed from ui-id-3
INFO: focus set on btnExpander8
INFO: focus removed from btnExpander8
INFO: Received ajax response (771 characters)
INFO:
<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="expandable17" ></component></ajax-response>
ERROR: Wicket.Ajax.Call.processComponent: Component with id [[expandable17]]
was not found while trying to perform markup update. Make sure you called
component.setOutputMarkupId(true) on the component whose markup you are
trying to update.
INFO: Response processed successfully.
INFO: refocus last focused component not needed/allowed
INFO: focus set on btnExpander8
INFO: focus removed from btnExpander8
INFO: focus set on wicketDebugLink
INFO: focus removed from wicketDebugLink
CODE:
PropertyListView<ShareActivityPlusDecode> activityLog = new
PropertyListView<ShareActivityPlusDecode>("activityLog", activities) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ShareActivityPlusDecode> item)
{
ShareActivityPlusDecode activity = (ShareActivityPlusDecode)
item.getDefaultModelObject();
item.add(new Label("CREATION_TIMESTAMP"));
item.add(new Label("ACTIVITY_DC"));
item.add(new ExternalLink("mailTo", "mailto:" +
activity.getEMAIL_ADR()).add(new Label("CREATED_BY_USER_ID")));
item.add(new Label("USER_PH"));
item.add(new AjaxButton("btnExpander"){
private static final long serialVersionUID = 1L;
public void onSubmit(AjaxRequestTarget target, Form form) {
WebMarkupContainer wmc = (WebMarkupContainer)
this.getParent().get("expandable");
onActivityLogExpansion(target, wmc, this);
}
}).setOutputMarkupId(true);
WebMarkupContainer expandable = new WebMarkupContainer("expandable", new
Model<ShareActivityPlusDecode>((ShareActivityPlusDecode)
item.getDefaultModel().getObject()));
expandable.add(new Label("EMAIL_ADR").setOutputMarkupId(true));
expandable.add(new Label("COMMENT").setOutputMarkupId(true));
boolean reject =
item.getModelObject().getACTIVITY_CD().equals(ACTIVITY_REJECT) ||
item.getModelObject().getACTIVITY_CD().equals(ACTIVITY_PENDING_AMENDMENT);
expandable.add(new Label("rejectionReasons", new
Model<String>("")).setVisible(reject).setEnabled(reject).setOutputMarkupId(true));
expandable.setVisible(false);
expandable.setOutputMarkupId(true);
item.add(expandable);
}
};
logForm.add(activityLog);
[...]
private void onActivityLogExpansion(AjaxRequestTarget target,
WebMarkupContainer wmc, AjaxButton invokingButton) {
Label rejectionReasons = (Label) wmc.get("rejectionReasons");
ShareActivityPlusDecode activity = (ShareActivityPlusDecode)
wmc.getDefaultModelObject();
if(rejectionReasons.isEnabled() &&
rejectionReasons.getDefaultModelObjectAsString().length()==0) {
//populate rejection reasons as this is a rejection activity and the
value isn't set yet
List<String> reasonDecodes =
this.sharingService.fetchRejectionReasons(activity.getACTIVITY_CD());
StringBuilder sb = new StringBuilder();
for(String reason:reasonDecodes)
sb.append(reason).append(", ");
if(sb.length()>=2)
sb.delete(sb.length()-2, sb.length());
Model<String> model = (Model<String>) rejectionReasons.getDefaultModel();
model.setObject(sb.toString());
}
wmc.setVisible(!wmc.isVisible());
target.add(wmc);
if(wmc.isVisible())
invokingButton.setLabel(new Model<String>("-"));
else
invokingButton.setLabel(new Model<String>("+"));
}
HTML:
Date
Activity
Request Decision
User Phone
<wicket:container wicket:id="activityLog">
<input type="button" wicket:id="btnExpander" value="+">
01/10/2014
01/15/2014
<span wicket:id="CREATED_BY_USER_ID"> <#>
Rejected-Pending Amendment
Rejected-Pending Amendment
<wicket:container wicket:id="expandable">
<label>Email:</label>
<label>Rejection Reasons:</label>
<label>Comments:</label>
</wicket:container>
</wicket:container>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Expandable-section-in-ListView-tp4665014.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
Re: Expandable section in ListView
Posted by Stefan Renz <s....@efonds.com>.
Hi,
try to setOutputMarkupPlaceholderTag(true) on your expandable, otherwise
your component doesn't render at all when setVisible(false)...
Bye
Stef
Entropy wrote:
> I have a list view that will have a button on the left to expand or contract
> a section that starts out hidden. this section will have some additional
> details. Code and HTML below.
>
> When I click the button, the event arrives in my onActivityLogExpansion, and
> the wicket ajax debug control turns red. The log says the following, that I
> did not setOutputMarkupdId to true. But I did as you can see in the code.
>
> INFO: focus set on ui-id-3
> INFO: focus removed from ui-id-3
> INFO: focus set on btnExpander8
> INFO: focus removed from btnExpander8
> INFO: Received ajax response (771 characters)
> INFO:
> <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> id="expandable17" ></component></ajax-response>
> ERROR: Wicket.Ajax.Call.processComponent: Component with id [[expandable17]]
> was not found while trying to perform markup update. Make sure you called
> component.setOutputMarkupId(true) on the component whose markup you are
> trying to update.
> INFO: Response processed successfully.
> INFO: refocus last focused component not needed/allowed
> INFO: focus set on btnExpander8
> INFO: focus removed from btnExpander8
> INFO: focus set on wicketDebugLink
> INFO: focus removed from wicketDebugLink
>
>
> CODE:
> PropertyListView<ShareActivityPlusDecode> activityLog = new
> PropertyListView<ShareActivityPlusDecode>("activityLog", activities) {
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(ListItem<ShareActivityPlusDecode> item)
> {
> ShareActivityPlusDecode activity = (ShareActivityPlusDecode)
> item.getDefaultModelObject();
> item.add(new Label("CREATION_TIMESTAMP"));
> item.add(new Label("ACTIVITY_DC"));
> item.add(new ExternalLink("mailTo", "mailto:" +
> activity.getEMAIL_ADR()).add(new Label("CREATED_BY_USER_ID")));
> item.add(new Label("USER_PH"));
> item.add(new AjaxButton("btnExpander"){
> private static final long serialVersionUID = 1L;
> public void onSubmit(AjaxRequestTarget target, Form form) {
> WebMarkupContainer wmc = (WebMarkupContainer)
> this.getParent().get("expandable");
> onActivityLogExpansion(target, wmc, this);
> }
> }).setOutputMarkupId(true);
>
> WebMarkupContainer expandable = new WebMarkupContainer("expandable", new
> Model<ShareActivityPlusDecode>((ShareActivityPlusDecode)
> item.getDefaultModel().getObject()));
> expandable.add(new Label("EMAIL_ADR").setOutputMarkupId(true));
> expandable.add(new Label("COMMENT").setOutputMarkupId(true));
> boolean reject =
> item.getModelObject().getACTIVITY_CD().equals(ACTIVITY_REJECT) ||
> item.getModelObject().getACTIVITY_CD().equals(ACTIVITY_PENDING_AMENDMENT);
> expandable.add(new Label("rejectionReasons", new
> Model<String>("")).setVisible(reject).setEnabled(reject).setOutputMarkupId(true));
> expandable.setVisible(false);
> expandable.setOutputMarkupId(true);
> item.add(expandable);
> }
> };
> logForm.add(activityLog);
>
> [...]
>
> private void onActivityLogExpansion(AjaxRequestTarget target,
> WebMarkupContainer wmc, AjaxButton invokingButton) {
> Label rejectionReasons = (Label) wmc.get("rejectionReasons");
> ShareActivityPlusDecode activity = (ShareActivityPlusDecode)
> wmc.getDefaultModelObject();
> if(rejectionReasons.isEnabled() &&
> rejectionReasons.getDefaultModelObjectAsString().length()==0) {
> //populate rejection reasons as this is a rejection activity and the
> value isn't set yet
> List<String> reasonDecodes =
> this.sharingService.fetchRejectionReasons(activity.getACTIVITY_CD());
> StringBuilder sb = new StringBuilder();
> for(String reason:reasonDecodes)
> sb.append(reason).append(", ");
> if(sb.length()>=2)
> sb.delete(sb.length()-2, sb.length());
> Model<String> model = (Model<String>) rejectionReasons.getDefaultModel();
> model.setObject(sb.toString());
> }
> wmc.setVisible(!wmc.isVisible());
> target.add(wmc);
> if(wmc.isVisible())
> invokingButton.setLabel(new Model<String>("-"));
> else
> invokingButton.setLabel(new Model<String>("+"));
> }
>
>
>
> HTML:
>
>
>
>
>
> Date
> Activity
> Request Decision
> User Phone
>
> <wicket:container wicket:id="activityLog">
>
>
> <input type="button" wicket:id="btnExpander" value="+">
> 01/10/2014
> 01/15/2014
> <span wicket:id="CREATED_BY_USER_ID"> <#>
> Rejected-Pending Amendment
> Rejected-Pending Amendment
>
> <wicket:container wicket:id="expandable">
>
>
>
> <label>Email:</label>
>
>
>
>
>
>
> <label>Rejection Reasons:</label>
>
>
>
>
>
>
> <label>Comments:</label>
>
>
>
> </wicket:container>
> </wicket:container>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Expandable-section-in-ListView-tp4665014.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
>
--
im Auftrag der eFonds Solutions AG, +49-89-579494-3417
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org