Example usage for com.liferay.portal.kernel.util UnicodeFormatter toString

List of usage examples for com.liferay.portal.kernel.util UnicodeFormatter toString

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util UnicodeFormatter toString.

Prototype

public static String toString(String s) 

Source Link

Usage

From source file:com.liferay.util.JS.java

License:Open Source License

public static String toScript(String[] array) {
    StringBundler sb = new StringBundler(array.length * 4 + 2);

    sb.append(StringPool.OPEN_BRACKET);//from w  w w.ja v a2s  .  com

    for (int i = 0; i < array.length; i++) {
        sb.append(StringPool.APOSTROPHE);
        sb.append(UnicodeFormatter.toString(array[i]));
        sb.append(StringPool.APOSTROPHE);

        if (i + 1 < array.length) {
            sb.append(StringPool.COMMA);
        }
    }

    sb.append(StringPool.CLOSE_BRACKET);

    return sb.toString();
}

From source file:org.apache.jsp.html.portlet.ext.cms.search.view_jsp.java

License:Open Source License

public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;/* ww  w  . j  a va 2  s.c om*/
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
        _jspxFactory = JspFactory.getDefaultFactory();
        response.setContentType("text/html; charset=UTF-8");
        pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
        _jspx_page_context = pageContext;
        application = pageContext.getServletContext();
        config = pageContext.getServletConfig();
        session = pageContext.getSession();
        out = pageContext.getOut();
        _jspx_out = out;

        /**
         * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
         *
         * Permission is hereby granted, free of charge, to any person obtaining a copy
         * of this software and associated documentation files (the "Software"), to deal
         * in the Software without restriction, including without limitation the rights
         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         * copies of the Software, and to permit persons to whom the Software is
         * furnished to do so, subject to the following conditions:
         *
         * The above copyright notice and this permission notice shall be included in
         * all copies or substantial portions of the Software.
         *
         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         * SOFTWARE.
         */

        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        //  liferay-theme:defineObjects
        com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                .get(com.liferay.taglib.theme.DefineObjectsTag.class);
        _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context);
        _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null);
        int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0
                .doStartTag();
        if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0
                .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                    .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
            return;
        }
        _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
        com.liferay.portal.theme.ThemeDisplay themeDisplay = null;
        com.liferay.portal.model.Company company = null;
        com.liferay.portal.model.Account account = null;
        com.liferay.portal.model.User user = null;
        com.liferay.portal.model.User realUser = null;
        com.liferay.portal.model.Contact contact = null;
        com.liferay.portal.model.Layout layout = null;
        java.util.List layouts = null;
        java.lang.Long plid = null;
        com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null;
        java.lang.Long portletGroupId = null;
        com.liferay.portal.kernel.security.permission.PermissionChecker permissionChecker = null;
        java.util.Locale locale = null;
        java.util.TimeZone timeZone = null;
        com.liferay.portal.model.Theme theme = null;
        com.liferay.portal.model.ColorScheme colorScheme = null;
        com.liferay.portal.theme.PortletDisplay portletDisplay = null;
        themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay");
        company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company");
        account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account");
        user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user");
        realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser");
        contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact");
        layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout");
        layouts = (java.util.List) _jspx_page_context.findAttribute("layouts");
        plid = (java.lang.Long) _jspx_page_context.findAttribute("plid");
        layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context
                .findAttribute("layoutTypePortlet");
        portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId");
        permissionChecker = (com.liferay.portal.kernel.security.permission.PermissionChecker) _jspx_page_context
                .findAttribute("permissionChecker");
        locale = (java.util.Locale) _jspx_page_context.findAttribute("locale");
        timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone");
        theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme");
        colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme");
        portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context
                .findAttribute("portletDisplay");
        out.write("\r\n");
        out.write("\r\n");

        /**
         * Copyright (c) 2000-2006 Liferay, LLC. All rights reserved.
         *
         * Permission is hereby granted, free of charge, to any person obtaining a copy
         * of this software and associated documentation files (the "Software"), to deal
         * in the Software without restriction, including without limitation the rights
         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         * copies of the Software, and to permit persons to whom the Software is
         * furnished to do so, subject to the following conditions:
         *
         * The above copyright notice and this permission notice shall be included in
         * all copies or substantial portions of the Software.
         *
         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         * SOFTWARE.
         */

        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        //@ page import="com.liferay.portal.kernel.util.PortletExtKeys" 
        out.write("\r\n");
        out.write("\r\n");

        String contextPath = PropsUtil.get(PropsUtil.PORTAL_CTX);
        if (contextPath.equals("/")) {
            contextPath = "";
        }

        out.write('\r');
        out.write('\n');
        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");
        out.write('\n');
        out.write('\n');
        //  portlet:defineObjects
        com.liferay.taglib.portlet.DefineObjectsTag _jspx_th_portlet_005fdefineObjects_005f0 = (com.liferay.taglib.portlet.DefineObjectsTag) _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                .get(com.liferay.taglib.portlet.DefineObjectsTag.class);
        _jspx_th_portlet_005fdefineObjects_005f0.setPageContext(_jspx_page_context);
        _jspx_th_portlet_005fdefineObjects_005f0.setParent(null);
        int _jspx_eval_portlet_005fdefineObjects_005f0 = _jspx_th_portlet_005fdefineObjects_005f0.doStartTag();
        if (_jspx_th_portlet_005fdefineObjects_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                    .reuse(_jspx_th_portlet_005fdefineObjects_005f0);
            return;
        }
        _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                .reuse(_jspx_th_portlet_005fdefineObjects_005f0);
        javax.portlet.PortletConfig portletConfig = null;
        java.lang.String portletName = null;
        javax.portlet.PortletPreferences portletPreferences = null;
        javax.portlet.PortletSession portletSession = null;
        javax.portlet.RenderRequest renderRequest = null;
        javax.portlet.RenderResponse renderResponse = null;
        portletConfig = (javax.portlet.PortletConfig) _jspx_page_context.findAttribute("portletConfig");
        portletName = (java.lang.String) _jspx_page_context.findAttribute("portletName");
        portletPreferences = (javax.portlet.PortletPreferences) _jspx_page_context
                .findAttribute("portletPreferences");
        portletSession = (javax.portlet.PortletSession) _jspx_page_context.findAttribute("portletSession");
        renderRequest = (javax.portlet.RenderRequest) _jspx_page_context.findAttribute("renderRequest");
        renderResponse = (javax.portlet.RenderResponse) _jspx_page_context.findAttribute("renderResponse");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");

        PortalPreferences prefs = PortletPreferencesFactoryUtil.getPortalPreferences(request);

        String namespace = "_GN_CMS_SEARCH_";

        PortletRequest portletRequest = (PortletRequest) request
                .getAttribute(com.liferay.portal.kernel.util.JavaConstants.JAVAX_PORTLET_REQUEST);

        com.ext.portlet.base.contentrel.ContentRelUtil relUtil = com.ext.portlet.base.contentrel.ContentRelUtil
                .getInstance();
        String[] classNames1 = relUtil.getPortletClassNames();
        String[] portletNames1 = relUtil.getPortletNames();

        out.write("\r\n");
        out.write("\r\n");
        out.write("\r\n");

        String defaultKeywords = LanguageUtil.get(pageContext, "search") + "...";
        String unicodeDefaultKeywords = UnicodeFormatter.toString(defaultKeywords);

        String keywords = ParamUtil.getString(request, "keywords", defaultKeywords);

        String searchLayout = GetterUtil.getString(PropsUtil.get("gi9.search.layout"), "");

        long searchPlid = 0;

        if (Validator.isNotNull(searchLayout)) {

            long companyId = PortalUtil.getCompanyId(request);

            Group group = null;

            try {
                group = GroupLocalServiceUtil.getFriendlyURLGroup(companyId, "/guest");

                Object[] friendlyURLMapper = PortalUtil.getPortletFriendlyURLMapper(request, group.getGroupId(),
                        false, searchLayout, null);

                Layout slayout = (Layout) friendlyURLMapper[0];
                searchPlid = slayout.getPlid();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
        PortletURL portletURL = null;
        if (searchPlid <= 0) {

            portletURL = new PortletURLImpl(request, "GN_CMS_SEARCH", plid.longValue(), false);
            portletURL.setWindowState(WindowState.MAXIMIZED);
        } else {
            portletURL = new PortletURLImpl(request, "GN_CMS_SEARCH", searchPlid, false);
            portletURL.setWindowState(WindowState.NORMAL);
        }

        portletURL.setPortletMode(PortletMode.VIEW);

        portletURL.setParameter("struts_action", "/ext/cms/search/search");
        ;

        out.write("\r\n");
        out.write("\r\n");
        out.write("<form action=\"");
        out.print(portletURL);
        out.write(
                "\" method=\"post\" name=\"GN_CMS_SEARCH_FORM\" onsubmit=\"submitForm(this); return false;\">\r\n");
        out.write("<legend>&nbsp;</legend>\r\n");
        out.write("<input type=\"hidden\" name=\"search\" value=\"true\">\r\n");
        out.write("<table >\r\n");
        out.write("  <tr>\r\n");
        out.write("    <td><input alt=\"");
        out.print(keywords);
        out.write("\" class=\"txt\" title=\"");
        out.print(keywords);
        out.write("\" name=\"");
        out.print(namespace);
        out.write("keywords\" size=\"23\" type=\"text\" value=\"");
        out.print(keywords);
        out.write("\" onBlur=\"if (this.value == '') { this.value = '");
        out.print(unicodeDefaultKeywords);
        out.write("'; }\" onFocus=\"if (this.value == '");
        out.print(unicodeDefaultKeywords);
        out.write("') { this.value = ''; }\" />\r\n");
        out.write("    </td>\r\n");
        out.write("    <td style=\"padding-left:3px;\">\r\n");
        out.write("    <input type=\"image\" alt=\"");
        if (_jspx_meth_liferay_002dui_005fmessage_005f0(_jspx_page_context))
            return;
        out.write("\" class=\"img\" title=\"");
        if (_jspx_meth_liferay_002dui_005fmessage_005f1(_jspx_page_context))
            return;
        out.write("\"  src=\"");
        out.print(themeDisplay.getPathThemeImages());
        out.write("/common/search.gif\" title=\"");
        if (_jspx_meth_liferay_002dui_005fmessage_005f2(_jspx_page_context))
            return;
        out.write("\" type=\"image\" \r\n");
        out.write("     onclick=\"if (document.GN_CMS_SEARCH_FORM.elements['");
        out.print(namespace);
        out.write("keywords'].value == null || \r\n");
        out.write("   \t\t document.GN_CMS_SEARCH_FORM.elements['");
        out.print(namespace);
        out.write("keywords'].value == '') { alert('");
        out.print(LanguageUtil.get(pageContext, "cms.search.please-input-criterion"));
        out.write("'); return false; }\" onkeypress=\"if (document.GN_CMS_SEARCH_FORM.elements['");
        out.print(namespace);
        out.write("keywords'].value == null || \r\n");
        out.write("   \t\t document.GN_CMS_SEARCH_FORM.elements['");
        out.print(namespace);
        out.write("keywords'].value == '') { alert('");
        out.print(LanguageUtil.get(pageContext, "cms.search.please-input-criterion"));
        out.write("'); return false; }\"/>\r\n");
        out.write("   </td>\r\n");
        out.write("  </tr>\r\n");
        out.write("</table>\r\n");
        out.write("\r\n");
        out.write("</form>");
    } catch (Throwable t) {
        if (!(t instanceof SkipPageException)) {
            out = _jspx_out;
            if (out != null && out.getBufferSize() != 0)
                out.clearBuffer();
            if (_jspx_page_context != null)
                _jspx_page_context.handlePageException(t);
        }
    } finally {
        if (_jspxFactory != null)
            _jspxFactory.releasePageContext(_jspx_page_context);
    }
}

From source file:se.gothiaforum.controller.actorsform.ViewActorsArticleController.java

License:Open Source License

/**
 * This is the action method that saves the values of the form and creates necessary model objects that
 * represents a actor./*from   w ww  . j  a va2  s . c  om*/
 * 
 * @param actorArticle
 *            the models that represents the Actors Article.
 * @param result
 *            result is a list of validation errors on the posted form.
 * @param tagsEntries
 *            the tag that is posted in to the form.
 * @param request
 *            the request
 * @param response
 *            the response
 * @param model
 *            the model
 */
@ActionMapping(params = "action=addActor")
public void addActor(@ModelAttribute("actorArticle") ActorArticle actorArticle, BindingResult result,
        @RequestParam("tagsEntries") String tagsEntries, ActionRequest request, ActionResponse response,
        Model model) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long userId = themeDisplay.getUserId();
    long defaultUserId = 0;

    try {
        defaultUserId = themeDisplay.getDefaultUserId();
        ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalArticle.class.getName(),
                request);

        // Checks for duplicates, if exists return a validate error.
        List<Organization> orgs = actorsService.getOrganizations(themeDisplay.getCompanyId());
        for (Organization o : orgs) {
            if (o.getName().equals(actorArticle.getCompanyName()) && actorArticle.getArticleId().isEmpty()) {
                result.rejectValue("companyName", "code.dublicate", "duplicate-companyName");
            }
        }

        actorArticle.setDetailedDescription(request.getParameter("descriptionEditor"));
        actorArticle.setDetailedDescriptionUnicoded(
                UnicodeFormatter.toString(actorArticle.getDetailedDescription()));

        validator.validate(actorArticle, result);

        if (result.hasErrors()) {
            model.addAttribute("errors", result);
        } else {
            if (actorArticle.getArticleId().isEmpty()) {
                actorsService.addActor(actorArticle, userId, defaultUserId, themeDisplay.getCompanyId(),
                        serviceContext, tagsEntries, themeDisplay.getScopeGroupId());
            } else {
                JournalArticle article = actorsService.updateActors(actorArticle, userId, serviceContext,
                        tagsEntries, themeDisplay.getScopeGroupId());
                Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class.getName());
                indexer.reindex(article);
            }
            actorArticle = getActorsArticle(request);
        }
    } catch (PortalException e) {
        throw new RuntimeException("Could not save the user", e);
    } catch (SystemException e) {
        throw new RuntimeException("Could not save the user", e);
    }

    model.addAttribute("actorArticle", actorArticle);
    model.addAttribute("tagsEntries", tagsEntries);

    // This sets the view page for the render phase.N
    response.setRenderParameter("view", "showImageActorsForm");

}

From source file:se.gothiaforum.controller.actorsform.ViewActorsArticleController.java

License:Open Source License

/**
 * Model Attribute for the Actors Article.
 * //w w w .  ja v a2s  . co m
 * @param request
 *            the request
 * 
 * @return a Actors Article.
 */
@ModelAttribute(value = "actorArticle")
public ActorArticle getActorsArticle(PortletRequest request) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    ActorArticle actorArticle = actorsService.getActorsArticle(themeDisplay);

    actorArticle
            .setDetailedDescriptionUnicoded(UnicodeFormatter.toString(actorArticle.getDetailedDescription()));

    return actorArticle;
}