-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More tags, example with listing and correction in the required VRapto…
…r version
- Loading branch information
Showing
8 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/br/com/caelum/vraptor/html/example/page/ListPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package br.com.caelum.vraptor.html.example.page; | ||
import static br.com.caelum.vraptor.html.PageTagFactory.body; | ||
import static br.com.caelum.vraptor.html.PageTagFactory.html; | ||
import static br.com.caelum.vraptor.html.PageTagFactory.li; | ||
import static br.com.caelum.vraptor.html.PageTagFactory.ol; | ||
|
||
import java.util.List; | ||
|
||
import br.com.caelum.vraptor.html.Page; | ||
import br.com.caelum.vraptor.html.tags.Html; | ||
import br.com.caelum.vraptor.html.tags.Tags; | ||
|
||
public class ListPage implements Page { | ||
|
||
private final List<String> cars; | ||
|
||
public ListPage(List<String> cars) { | ||
this.cars = cars; | ||
} | ||
|
||
@Override | ||
public Html render() { | ||
return html( | ||
body( | ||
ol( | ||
cars() | ||
) | ||
) | ||
); | ||
} | ||
|
||
// private Tag toTag(String car) { | ||
// ...; | ||
// } | ||
|
||
private Tags cars() { | ||
//Tags.foreach(cars).use(TablePage.class).toTag(null); | ||
|
||
|
||
Tags tags = new Tags(); | ||
for (String car : cars) { | ||
tags.append(li(car)); | ||
} | ||
return tags; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package br.com.caelum.vraptor.html.tags; | ||
|
||
import br.com.caelum.vraptor.html.attributes.Attributes; | ||
|
||
public class Li implements Tag { | ||
private final Attributes attributes; | ||
private final Tag[] children; | ||
|
||
public Li(Attributes attributes, Tag... children) { | ||
this.attributes = attributes; | ||
this.children = children; | ||
|
||
} | ||
|
||
@Override | ||
public Tag[] getChildren() { | ||
return children; | ||
} | ||
|
||
@Override | ||
public Attributes getAttributes() { | ||
return attributes; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package br.com.caelum.vraptor.html.tags; | ||
|
||
import br.com.caelum.vraptor.html.attributes.Attributes; | ||
|
||
public class Ol implements Tag { | ||
private final Tag[] children; | ||
private final Attributes attributes; | ||
|
||
public Ol(Attributes attributes, Tag... children) { | ||
this.attributes = attributes; | ||
this.children = children; | ||
} | ||
|
||
public Attributes getAttributes() { | ||
return this.attributes; | ||
} | ||
|
||
public Tag[] getChildren() { | ||
return this.children; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package br.com.caelum.vraptor.html.tags; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import br.com.caelum.vraptor.html.attributes.Attributes; | ||
|
||
public class Tags implements Tag { | ||
|
||
private final List<Tag> children = new LinkedList<Tag>(); | ||
|
||
@Override | ||
public Tag[] getChildren() { | ||
return children.toArray(new Tag[0]); | ||
} | ||
|
||
@Override | ||
public Attributes getAttributes() { | ||
return new Attributes(); | ||
} | ||
|
||
public void append(Tag child) { | ||
children.add(child); | ||
} | ||
|
||
} |