Skip to content

Instantly share code, notes, and snippets.

@stefanwendelmann
Created September 19, 2017 13:27
Show Gist options
  • Select an option

  • Save stefanwendelmann/ccc1ac9ec675c8efca08a4b911e6bed8 to your computer and use it in GitHub Desktop.

Select an option

Save stefanwendelmann/ccc1ac9ec675c8efca08a4b911e6bed8 to your computer and use it in GitHub Desktop.
nav
public static Object createManagedBean(String aName)
{
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
// Bean löschen
deleteManagedBean(aName);
// Bean setzen
//Object result = app.getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(), aName);
Object result = app.getELResolver().getValue(fc.getELContext(), null, aName);
return result;
}
public static String openNewPage(String aWebPage, boolean redirect)
{
Object webPage = createManagedBean(QString.firstToLower(aWebPage));
String target = aWebPage;
if (redirect)
{
target += "?faces-redirect=true";
}
return target;
}
public String jump(String aTargetPage)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
String viewId = facesContext.getViewRoot().getViewId();
String beanname = WebHelper.pageName2Bean(viewId);
Object bean = WebHelper.createManagedBean(beanname);
if (bean != null && bean instanceof BaseWebPage)
{
if (!((BaseWebPage) bean).canClose(aTargetPage))
{
return null;
}
}
return WebHelper.openNewPage(aTargetPage, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment