org.efaps.ui.wicket.components.footer.AjaxReviseLink Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of efaps-webapp Show documentation
Show all versions of efaps-webapp Show documentation
eFaps WebApp provides a web interface as the User Interface for eFaps
which can be easily expanded and altered.
/*
* Copyright 2003 - 2012 The eFaps Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Revision: $Rev: 8386 $
* Last Changed: $Date: 2012-12-14 15:45:34 -0500 (Fri, 14 Dec 2012) $
* Last Changed By: $Author: [email protected] $
*/
package org.efaps.ui.wicket.components.footer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.model.Model;
import org.efaps.ui.wicket.components.modalwindow.ModalWindowContainer;
import org.efaps.ui.wicket.models.FormModel;
import org.efaps.ui.wicket.models.TableModel;
import org.efaps.ui.wicket.models.objects.AbstractUIObject;
import org.efaps.ui.wicket.models.objects.AbstractUIPageObject;
import org.efaps.ui.wicket.models.objects.UIForm;
import org.efaps.ui.wicket.models.objects.UITable;
import org.efaps.ui.wicket.models.objects.UIWizardObject;
import org.efaps.ui.wicket.pages.content.AbstractContentPage;
import org.efaps.ui.wicket.pages.content.form.FormPage;
import org.efaps.ui.wicket.pages.content.table.TablePage;
import org.efaps.ui.wicket.pages.error.ErrorPage;
import org.efaps.util.EFapsException;
/**
* Class renders a Link used on a search result to return to the previous page
* and revise the search.
*
* @author The eFaps Team
* @version $Id: AjaxReviseLink.java 8386 2012-12-14 20:45:34Z [email protected] $
*/
public class AjaxReviseLink
extends AjaxLink
{
/**
* Needed for serialization.
*/
private static final long serialVersionUID = 1L;
/**
* @param _wicketId wicket id of this component
* @param _uiObject uiobject for this component
*/
public AjaxReviseLink(final String _wicketId,
final AbstractUIObject _uiObject)
{
super(_wicketId, new Model(_uiObject));
}
/**
* On click the previous page will be restored using wizard from the
* uiobject.
*
* @param _target target for this request
*/
@Override
public void onClick(final AjaxRequestTarget _target)
{
final AbstractUIPageObject uiobject = (AbstractUIPageObject) getDefaultModelObject();
final UIWizardObject wizard = uiobject.getWizard();
final AbstractUIPageObject prevObject = wizard.getPrevious();
prevObject.setPartOfWizardCall(true);
prevObject.resetModel();
final FooterPanel footer = findParent(FooterPanel.class);
final ModalWindowContainer modal = footer.getModalWindow();
final AbstractContentPage page;
try {
if (prevObject instanceof UITable) {
page = new TablePage(new TableModel((UITable) prevObject), modal);
} else {
page = new FormPage(new FormModel((UIForm) prevObject), modal);
}
getRequestCycle().setResponsePage(page);
} catch (final EFapsException e) {
getRequestCycle().setResponsePage(new ErrorPage(e));
}
}
}