Package org.internna.iwebmvc.model.core

Examples of org.internna.iwebmvc.model.core.I18nText


    @BeanConstraint
    private Color color;

    @Override
    public void initialize(ContextHolder context) {
        name = new I18nText();
        name.initialize(context);
        color = new Color();
    }
View Full Code Here


                list.add(l);
                return list;
            }
        });
        binder.setAsText("key=0001\nvalues=en-K");
        I18nText i = (I18nText) binder.getValue();
        assertEquals("0001", i.getKey());
        assertEquals("K", i.getValues().get(0).getLocalizedValue());
    }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public void setAsText(String text) throws IllegalArgumentException {
        I18nText i18n = (I18nText) getValue();
        Properties properties = new Properties();
        try {
            properties.load(IOUtils.toInputStream(text));
            if (i18n == null) {
                i18n = new I18nText();
                i18n.initialize(context);
            }
            i18n.setKey(properties.getProperty("key"));
            for (String tk : properties.getProperty("values").split("#,#")) {
                String[] i18ndata = StringUtils.split(tk, "-");
                for (LocalizedValue value : i18n.getValues())
                    if (value.getLocale().getLocale().equals(i18ndata[0]))
                        value.setLocalizedValue(i18ndata[1]);
            }
        } catch (Exception ex) {
            log.debug("Could not bind I18nText object from [" + text + "]");
View Full Code Here

        Classification c = new Classification();
        c.setColor(new Color());
        c.getColor().setRed(100);c.getColor().setGreen(100);c.getColor().setBlue(20);
        c.setLetter("A");
        c.setNumber(1);
        c.setName(new I18nText());
        c.getName().setKey("key.1");
        c.getName().setValues(new ArrayList<LocalizedValue>(2));
        c.getName().getValues().add(new LocalizedValue());
        c.getName().getValues().get(0).setLocale(en);
        c.getName().getValues().get(0).setLocalizedValue("one");
        c.getName().getValues().add(new LocalizedValue());
        c.getName().getValues().get(1).setLocale(es);
        c.getName().getValues().get(1).setLocalizedValue("uno");
        managerImpl.dao.create(c);
        Classification c2 = new Classification();
        c2.setColor(new Color());
        c2.getColor().setRed(20);c2.getColor().setGreen(100);c2.getColor().setBlue(100);
        c2.setLetter("B");
        c2.setNumber(2);
        c2.setName(new I18nText());
        c2.getName().setKey("key.2");
        c2.getName().setValues(new ArrayList<LocalizedValue>(2));
        c2.getName().getValues().add(new LocalizedValue());
        c2.getName().getValues().get(0).setLocale(en);
        c2.getName().getValues().get(0).setLocalizedValue("two");
View Full Code Here

        validator.contextHolder = holder;
    }

    @Test
    public void validate() throws Exception {
        I18nText i = new I18nText();
        i.initialize(holder);
        Collection<FieldError> error = (Collection<FieldError>) validator.validate(stubs.validation.FakeDomainEntity.class, "name", i);
        assertNotNull("Validation error", error);
        assertTrue("Two field errors", error.size() == 2);
    }
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.model.core.I18nText

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.