Search in sources :

Example 31 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class BrowseBean method setDashboardView.

/**
 * @param dashboardView The dashboard view mode to set.
 */
public void setDashboardView(boolean dashboardView) {
    this.dashboardView = dashboardView;
    if (dashboardView == true) {
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dashboard");
    }
}
Also used : FacesContext(javax.faces.context.FacesContext)

Example 32 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class BrowseBean method viewModeChanged.

// ------------------------------------------------------------------------------
// Navigation action event handlers
/**
 * Change the current view mode based on user selection
 *
 * @param event      ActionEvent
 */
public void viewModeChanged(ActionEvent event) {
    UIModeList viewList = (UIModeList) event.getComponent();
    // get the view mode ID
    String viewMode = viewList.getValue().toString();
    if (VIEWMODE_DASHBOARD.equals(viewMode) == false) {
        // set the page size based on the style of display
        int pageSize = this.viewsConfig.getDefaultPageSize(PAGE_NAME_BROWSE, viewMode);
        setPageSizeContent(pageSize);
        setPageSizeSpaces(pageSize);
        if (logger.isDebugEnabled())
            logger.debug("Browse view page size set to: " + pageSize);
        setDashboardView(false);
        // push the view mode into the lists
        setBrowseViewMode(viewMode);
        // setup dispatch context for custom views
        this.navigator.setupDispatchContext(this.navigator.getCurrentNode());
        // browse to appropriate view
        FacesContext fc = FacesContext.getCurrentInstance();
        String outcome = null;
        String viewId = fc.getViewRoot().getViewId();
        if (viewId.equals(BROWSE_VIEW_ID) == false && viewId.equals(CATEGORY_VIEW_ID) == false) {
            outcome = "browse";
        }
        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, outcome);
    } else {
        // special case for Dashboard view
        setDashboardView(true);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UIModeList(org.alfresco.web.ui.common.component.UIModeList)

Example 33 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class AdminNodeBrowseBean method submitSearch.

/**
 * Action to submit search
 *
 * @return next action
 */
public String submitSearch() {
    long start = System.currentTimeMillis();
    RetryingTransactionCallback<String> searchCallback = new RetryingTransactionCallback<String>() {

        public String execute() throws Throwable {
            if (queryLanguage.equals("noderef")) {
                // ensure node exists
                NodeRef nodeRef = new NodeRef(query);
                boolean exists = getNodeService().exists(nodeRef);
                if (!exists) {
                    throw new AlfrescoRuntimeException("Node " + nodeRef + " does not exist.");
                }
                setNodeRef(nodeRef);
                return "node";
            } else if (queryLanguage.equals("selectnodes")) {
                List<NodeRef> nodes = getSearchService().selectNodes(getNodeRef(), query, null, getNamespaceService(), false);
                searchResults = new SearchResults(nodes);
                return "search";
            }
            // perform search
            searchResults = new SearchResults(getSearchService().query(getNodeRef().getStoreRef(), queryLanguage, query));
            return "search";
        }
    };
    try {
        String result = getTransactionService().getRetryingTransactionHelper().doInTransaction(searchCallback, true);
        this.searchElapsedTime = System.currentTimeMillis() - start;
        return result;
    } catch (Throwable e) {
        FacesContext context = FacesContext.getCurrentInstance();
        FacesMessage message = new FacesMessage();
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        message.setDetail("Search failed due to: " + e.toString());
        context.addMessage("searchForm:query", message);
        return "error";
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FacesContext(javax.faces.context.FacesContext) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ArrayList(java.util.ArrayList) List(java.util.List) FacesMessage(javax.faces.application.FacesMessage)

Example 34 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class ImportDialog method reset.

/**
 * Resets the dialog state back to the default
 */
public void reset() {
    this.file = null;
    this.fileName = null;
    this.runInBackground = true;
    // delete the temporary file we uploaded earlier
    if (this.file != null) {
        this.file.delete();
    }
    // remove the file upload bean from the session
    FacesContext ctx = FacesContext.getCurrentInstance();
    ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
}
Also used : FacesContext(javax.faces.context.FacesContext)

Example 35 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class ImportDialog method getContainerTitle.

@Override
public String getContainerTitle() {
    FacesContext fc = FacesContext.getCurrentInstance();
    String name = Application.getMessage(fc, MSG_LEFT_QUOTE) + browseBean.getActionSpace().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
    return MessageFormat.format(Application.getMessage(fc, MSG_IMPORT_TITLE), name);
}
Also used : FacesContext(javax.faces.context.FacesContext)

Aggregations

FacesContext (javax.faces.context.FacesContext)361 NodeRef (org.alfresco.service.cmr.repository.NodeRef)61 Node (org.alfresco.web.bean.repository.Node)44 UserTransaction (javax.transaction.UserTransaction)43 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)27 ExternalContext (javax.faces.context.ExternalContext)26 SelectItem (javax.faces.model.SelectItem)26 QName (org.alfresco.service.namespace.QName)25 FacesMessage (javax.faces.application.FacesMessage)24 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Map (java.util.Map)21 ResourceBundle (java.util.ResourceBundle)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 MapNode (org.alfresco.web.bean.repository.MapNode)18 UIViewRoot (javax.faces.component.UIViewRoot)17 HttpServletRequest (javax.servlet.http.HttpServletRequest)16 Serializable (java.io.Serializable)15