Package org.apache.struts.util

Examples of org.apache.struts.util.MessageResources


     * @param isOnClick weather the path is to be used in an onClick.
     * @return String the wrapped String
     */
    private static String getTaskPath(String path, String bundle, String name, ServletContext context, Locale locale, int width,
                                     int height, boolean isOnClick) {
        MessageResources messageResources = CoreUtil.getMessageResources(context, bundle);
        String title = messageResources == null ? "<Unknown>" : messageResources.getMessage(locale, "taskProgress." + name
                        + ".title");
        StringBuilder taskString = new StringBuilder("Modalbox.show('");
        taskString.append(title);
        taskString.append("', '/taskProgress.do?url=");
        taskString.append(Util.urlEncode(path));
View Full Code Here


                Collection<PropertyDefinition> l = propertyClass.getDefinitions();
                String category = request.getParameter("category");
                for (PropertyDefinition d : l) {
                    AttributeDefinition def = (AttributeDefinition) d;
                    String categoryLabel = def.getCategoryLabel();
                    MessageResources mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey());
                    String s = mr == null ? null : mr.getMessage("userAttributeCategory." + def.getCategory() + ".title");
                    if (s != null && !s.equals("")) {
                        categoryLabel = Util.urlDecode(s);
                    } else {
                        categoryLabel = categoryLabel == null || categoryLabel.equals("") ? "Attributes" : categoryLabel;
                    }
View Full Code Here

    public String getResourceTypeName(PageContext pageContext) throws JspException {
        ResourceType rt = getFavoriteItem().getResource() == null ? null : getFavoriteItem().getResource().getResourceType();
        if (rt == null) {
            return "?";
        } else {
            MessageResources mr = TagUtils.getInstance().retrieveMessageResources(pageContext, rt.getBundle(), false);
            rt.getBundle();
            if (mr == null) {
                return "!Invalid bundle!";
            } else {
                String msg = mr.getMessage("resourceType." + rt.getResourceTypeId() + ".title");
                return msg == null || msg.equals("") ? "!No message!" : msg;
            }
        }

    }
View Full Code Here

     *
     * @param session session
     * @return localised text
     */
    public String getLocalizedMessage(HttpSession session) {
        MessageResources mr = getMessageResources(session, bundleActionMessage.getBundle());
        if(mr == null) {
            return "[Could not locate message resources for bundle "+ bundleActionMessage.getBundle() +"]";
        }
        Locale l = (Locale)session.getAttribute(Globals.LOCALE_KEY);
        l = l == null ? Locale.getDefault() : l;
        String message = mr.getMessage(l, bundleActionMessage.getKey(), bundleActionMessage.getArg0(), bundleActionMessage.getArg1(), bundleActionMessage.getArg2(), bundleActionMessage.getArg3());
        if(message == null) {
            message = super.getMessage();
        }
        return message;
    }
View Full Code Here

   
    /* (non-Javadoc)
     * @see java.lang.Throwable#getLocalizedMessage()
     */
    public String getMessage() {
        MessageResources cmr = getMessageResources(getBundle());
        String message = null;
        if(cmr != null) {
            message = cmr.getMessage(bundleActionMessage.getKey(),  bundleActionMessage.getArg0(), bundleActionMessage.getArg1(), bundleActionMessage.getArg2(), bundleActionMessage.getArg3());
        }
        if(message == null) {
            message = super.getMessage();
        }
        return message;
View Full Code Here

    public void initialize(HttpSession session, Collection<AttributeDefinition> definitions) throws Exception {
        super.initialize(session, "name");
        for (AttributeDefinition def : definitions) {
            if (def.isHidden() || def.getPropertyClass().getName().equals(ResourceAttributes.NAME))
                continue;
            MessageResources mr = null;
            if (def.getMessageResourcesKey() != null) {
                mr = CoreUtil.getMessageResources(session, def.getMessageResourcesKey());
            }
            Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
            AttributeDefinitionItem item = new AttributeDefinitionItem(locale, def, mr);
View Full Code Here

                    TypeMetaListItem item = (TypeMetaListItem) i.next();
                    ServletContext context = CoreServlet.getServlet().getServletContext();
                    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);
                    String mrKey = (item.getMessageResourcesKey() == null ? "properties" : item.getMessageResourcesKey())
                                    + moduleConfig.getPrefix();
                    MessageResources res = (MessageResources) context.getAttribute(mrKey);
                    String k = definition.getName() + ".value." + item.getValue();
                    String v = "";
                    if (res != null) {
                        v = res.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY), k);
                        if (v == null) {
                            v = item.getValue();
                        }
                    }
                    Pair pair = new Pair(item.getValue(), v);
View Full Code Here

         * @param definition
         * @param request
         * @param subcategory for if the category is split into sub categories.
         */
        public AbstractPropertyItem(PropertyDefinition definition, HttpServletRequest request, String subcategory) {
            MessageResources messageResources = null;
        if (definition.getMessageResourcesKey() != null) {
            messageResources = CoreUtil.getMessageResources(request.getSession(), definition.getMessageResourcesKey());
        }

        this.definition = definition;

        categoryLabel = this.definition.getCategoryLabel();
        String messageId = subcategory == null ? "attributeCategory." + definition.getCategory() + ".title" : "attributeCategory."
                        + definition.getCategory() + "." + subcategory + ".title";
       
        Locale locale = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);
        // Get an internationalised category label if possible
        String s = messageResources == null ? null : messageResources.getMessage(locale, messageId);
        if (s != null && !s.equals("")) {
            this.categoryLabel = s;
        } else {
            if (categoryLabel == null || categoryLabel.equals("")) {
                this.categoryLabel = "Attributes";
            }
        }

        label = this.definition.getLabel();
        // Get an internationalised label if possible, otherwise use default
        // label, otherwise use name
        s = messageResources == null ? null : messageResources.getMessage(locale, this.definition.getPropertyClass().getName() + "."
                        + definition.getName() + ".title");
        if (s != null && !s.equals("")) {
            label = s;
        } else {
            if (label != null && label.equals("")) {
                label = definition.getName();
            }
        }

        if (getCategoryLabel() != null)
            categoryId = Util.makeConstantKey(getCategoryLabel());

        // If there are ApplicationResources for the definition then set the
        // label and description with these.
        String tmpLabel = messageResources == null ? null : messageResources.getMessage(locale, definition.getNameMessageResourceKey());
        if (tmpLabel != null) {
            this.definition.setLabel(tmpLabel);
            label = tmpLabel;
        }
        String description = messageResources == null ? null : messageResources.getMessage(locale, definition
                        .getDescriptionMessageResourceKey());
        if (description != null) {
            this.definition.setDescription(description);
        }
    }
View Full Code Here

        if (moduleConfig != defaultConfig && defaultConfig != null) {
          messages = defaultConfig.findMessageResourcesConfig(bundle);
        }
        if (messages == null) {  // no messages declared --> install message resources
          MessageResourcesFactory.setFactoryClass(PropertyMessageResourcesFactory.class.getName());
          MessageResources resources = MessageResourcesFactory.createFactory().createResources(bundle);
          context.setAttribute(bundle, resources);
        }
      }   
    }
    }
View Full Code Here

                    TypeMetaListItem item = (TypeMetaListItem) i.next();
                    ServletContext context = CoreServlet.getServlet().getServletContext();
                    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);
                    String mrKey = (item.getMessageResourcesKey() == null ? "properties" : item.getMessageResourcesKey())
                                    + moduleConfig.getPrefix();
                    MessageResources res = (MessageResources) context.getAttribute(mrKey);
                    String k = definition.getName() + ".value." + item.getValue();
                    String v = "";
                    if (res != null) {
                        v = res.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY), k);
                        if (v == null) {
                            v = item.getValue();
                        }
                    }
                    Pair pair = new Pair(item.getValue(), v);
View Full Code Here

TOP

Related Classes of org.apache.struts.util.MessageResources

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.