Package org.apache.tiles

Examples of org.apache.tiles.Attribute


     *
     * @throws IOException If something goes wrong during rendition.
     */
    public void testWriteDefinition() throws IOException {
        StringWriter writer = new StringWriter();
        Attribute attribute = new Attribute("my.definition", null, "definition");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
View Full Code Here


     *
     * @throws IOException If something goes wrong during rendition.
     */
    public void testWriteString() throws IOException {
        StringWriter writer = new StringWriter();
        Attribute attribute = new Attribute("Result", null, "string");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
View Full Code Here

     *
     * @throws IOException If something goes wrong during rendition.
     */
    public void testWriteTemplate() throws IOException {
        StringWriter writer = new StringWriter();
        Attribute attribute = new Attribute("/myTemplate.jsp", null, "template");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
View Full Code Here

     * {@link AbstractBaseAttributeRenderer#render(Attribute, Writer, Object...)}.
     *
     * @throws IOException If something goes wrong during rendition.
     */
    public void testRender() throws IOException {
        Attribute attribute = new Attribute();
        StringWriter writer = new StringWriter();
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
View Full Code Here

     *
     * @throws IOException If something goes wrong, but it's not a Tiles
     * exception.
     */
    public void testObjectAttribute() throws IOException {
        Attribute attribute = new Attribute();
        TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.replay(request);
        boolean exceptionFound = false;

        attribute.setValue(new Integer(SAMPLE_INT)); // A simple object
        try {
            container.render(attribute, null, request);
        } catch (TilesException e) {
            LOG.debug("Intercepted a TilesException, it is correct", e);
            exceptionFound = true;
View Full Code Here

     */
    public void testAttributeCredentials() throws IOException {
        TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.expect(request.isUserInRole("myrole")).andReturn(Boolean.TRUE);
        EasyMock.replay(request);
        Attribute attribute = new Attribute((Object) "This is the value", "myrole");
        attribute.setRenderer("string");
        StringWriter writer = new StringWriter();
        container.render(attribute, writer, request);
        writer.close();
        assertEquals("The attribute should have been rendered",
                "This is the value", writer.toString());
View Full Code Here

     * Tests {@link BasicTilesContainer#evaluate(Attribute, Object...)}.
     */
    public void testEvaluate() {
        TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.replay(request);
        Attribute attribute = new Attribute((Object) "This is the value");
        Object value = container.evaluate(attribute, request);
        assertEquals("The attribute has not been evaluated correctly",
                "This is the value", value);
    }
View Full Code Here

        nudef.setPreparer(replace(d.getPreparer(), vars));
        nudef.setRole(replace(d.getRole(), vars));
        nudef.setTemplate(replace(d.getTemplate(), vars));

        for (String attributeName : d.getLocalAttributeNames()) {
            Attribute attr = d.getLocalAttribute(attributeName);
            Attribute nuattr = new Attribute();

            nuattr.setRole(replace(attr.getRole(), vars));
            nuattr.setRenderer(attr.getRenderer());

            Object value = attr.getValue();
            if (value instanceof String) {
                value = replace((String) value, vars);
            }
            nuattr.setValue(value);

            nudef.putAttribute(replace(attributeName, vars), nuattr);
        }

        return nudef;
View Full Code Here

      // initialize the session before rendering any fragments. Otherwise views that require the session which has
      // not otherwise been initialized will fail to render
      request.getSession();
      response.flushBuffer();
      for (int i = 0; i < attrNames.length; i++) {
        Attribute attributeToRender = (Attribute) flattenedAttributeMap.get(attrNames[i]);

        if (attributeToRender == null) {
          throw new ServletException("No tiles attribute with a name of '" + attrNames[i]
              + "' could be found for the current view: " + this);
        } else {
View Full Code Here

  private void flattenAttributeMap(BasicTilesContainer container, TilesRequestContext requestContext, Map resultMap,
      Definition compositeDefinition) throws Exception {
    Iterator i = compositeDefinition.getAttributes().keySet().iterator();
    while (i.hasNext()) {
      Object key = i.next();
      Attribute attr = (Attribute) compositeDefinition.getAttributes().get(key);
      Definition nestedDefinition = container.getDefinitionsFactory().getDefinition(attr.getValue().toString(),
          requestContext);
      resultMap.put(key, attr);
      if (nestedDefinition != null) {
        flattenAttributeMap(container, requestContext, resultMap, nestedDefinition);
      }
View Full Code Here

TOP

Related Classes of org.apache.tiles.Attribute

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.