use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UINavigator method broadcast.
/**
* @see javax.faces.component.UIInput#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof NavigatorEvent) {
FacesContext context = FacesContext.getCurrentInstance();
NavigatorEvent navEvent = (NavigatorEvent) event;
// node or panel selected?
switch(navEvent.getMode()) {
case PANEL_SELECTED:
{
String panelSelected = navEvent.getItem();
// a panel was selected, setup the context to make the panel
// the focus
NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
if (nb != null) {
try {
if (logger.isDebugEnabled())
logger.debug("Selecting panel: " + panelSelected);
nb.processToolbarLocation(panelSelected, true);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NOHOME), Application.getCurrentUser(context).getHomeSpaceId()), refErr);
} catch (Exception err) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
}
}
break;
}
case NODE_SELECTED:
{
// a node was clicked in the tree
boolean nodeExists = true;
NodeRef nodeClicked = new NodeRef(navEvent.getItem());
// make sure the node exists still before navigating to it
UserTransaction tx = null;
try {
tx = Repository.getUserTransaction(context, true);
tx.begin();
NodeService nodeSvc = Repository.getServiceRegistry(context).getNodeService();
nodeExists = nodeSvc.exists(nodeClicked);
tx.commit();
} catch (Throwable err) {
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
if (nodeExists) {
// setup the context to make the node the current node
BrowseBean bb = (BrowseBean) FacesHelper.getManagedBean(context, BrowseBean.BEAN_NAME);
if (bb != null) {
if (logger.isDebugEnabled())
logger.debug("Selected node: " + nodeClicked);
bb.clickSpace(nodeClicked);
}
} else {
String msg = Application.getMessage(context, "navigator_node_deleted");
Utils.addErrorMessage(msg);
}
break;
}
}
} else {
super.broadcast(event);
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UISimpleSearch method broadcast.
/**
* @see javax.faces.component.UICommand#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException {
FacesContext fc = getFacesContext();
if (event instanceof SearchEvent) {
// update the component parameters from the search event details
SearchEvent searchEvent = (SearchEvent) event;
// construct the Search Context object
SearchContext context = new SearchContext();
context.setText(searchEvent.SearchText);
context.setMode(searchEvent.SearchMode);
context.setForceAndTerms(Application.getClientConfig(fc).getForceAndTerms());
context.setSimpleSearchAdditionalAttributes(Application.getClientConfig(fc).getSimpleSearchAdditionalAttributes());
this.search = context;
super.broadcast(event);
} else if (event instanceof AdvancedSearchEvent) {
// special case to navigate to the advanced search screen
AdvancedSearchEvent searchEvent = (AdvancedSearchEvent) event;
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, searchEvent.Outcome);
// NOTE: we don't call super() here so that our nav outcome is the one that occurs!
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UICategoryBrowser method broadcast.
/*
* (non-Javadoc)
*
* @see org.alfresco.extension.web.ui.repo.component.UINavigator#broadcast(javax.faces.event.FacesEvent)
*/
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof CategoryBrowserEvent) {
FacesContext context = FacesContext.getCurrentInstance();
CategoryBrowserEvent categoryBrowseEvent = (CategoryBrowserEvent) event;
NodeRef nodeClicked = new NodeRef(categoryBrowseEvent.getItem());
boolean subcategories = categoryBrowseEvent.isIncludeSubcategories();
if (logger.isDebugEnabled())
logger.debug("Selected category: " + nodeClicked + " subcategories? " + subcategories);
CategoryBrowserBean categoryBrowserBean = (CategoryBrowserBean) FacesHelper.getManagedBean(context, CategoryBrowserBean.BEAN_NAME);
categoryBrowserBean.setCurrentCategory(nodeClicked);
categoryBrowserBean.setIncludeSubcategories(subcategories);
SearchContext categorySearch = categoryBrowserBean.generateCategorySearchContext();
NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
nb.setSearchContext(categorySearch);
context.getApplication().getNavigationHandler().handleNavigation(context, null, "category-browse");
} else {
super.broadcast(event);
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class XMLDateConverter method getLocale.
/**
* @see javax.faces.convert.DateTimeConverter#getLocale()
*/
@Override
public Locale getLocale() {
// get the locale set in the client
FacesContext context = FacesContext.getCurrentInstance();
Locale locale = context.getViewRoot().getLocale();
if (locale == null) {
// else use server locale as the default
locale = Locale.getDefault();
}
return locale;
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UploadInputTag method setProperties.
@SuppressWarnings("unchecked")
protected void setProperties(UIComponent component) {
super.setProperties(component);
FacesContext context = getFacesContext();
if (null != framework) {
if (isValueReference(framework)) {
ValueBinding vb = context.getApplication().createValueBinding(framework);
component.setValueBinding("maxlength", vb);
} else {
component.getAttributes().put("framework", framework);
}
}
component.getAttributes().put("immediate", true);
component.getAttributes().put("style", "display:none;");
}
Aggregations