| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.corelib.components; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.*; |
| 18 | |
import org.apache.tapestry5.annotations.Parameter; |
| 19 | |
import org.apache.tapestry5.annotations.SupportsInformalParameters; |
| 20 | |
import org.apache.tapestry5.dom.Element; |
| 21 | |
import org.apache.tapestry5.ioc.annotations.Inject; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
@SupportsInformalParameters |
| 27 | 110 | public class Any implements ClientElement |
| 28 | |
{ |
| 29 | |
@Parameter(defaultPrefix = BindingConstants.LITERAL) |
| 30 | |
private String element; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
@Parameter(value = "prop:componentResources.id", defaultPrefix = BindingConstants.LITERAL) |
| 36 | |
private String clientId; |
| 37 | |
|
| 38 | |
private Element anyElement; |
| 39 | |
|
| 40 | |
private String uniqueId; |
| 41 | |
|
| 42 | |
@Inject |
| 43 | |
private ComponentResources resources; |
| 44 | |
|
| 45 | |
@Inject |
| 46 | |
private RenderSupport renderSupport; |
| 47 | |
|
| 48 | |
String defaultElement() |
| 49 | |
{ |
| 50 | 106 | return resources.getElementName("div"); |
| 51 | |
} |
| 52 | |
|
| 53 | |
void beginRender(MarkupWriter writer) |
| 54 | |
{ |
| 55 | 9900 | anyElement = writer.element(element); |
| 56 | |
|
| 57 | 9900 | uniqueId = null; |
| 58 | |
|
| 59 | 9900 | resources.renderInformalParameters(writer); |
| 60 | 9900 | } |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
public String getClientId() |
| 71 | |
{ |
| 72 | 4 | if (uniqueId == null) |
| 73 | |
{ |
| 74 | 2 | uniqueId = renderSupport.allocateClientId(clientId); |
| 75 | 2 | anyElement.forceAttributes("id", uniqueId); |
| 76 | |
} |
| 77 | |
|
| 78 | 4 | return uniqueId; |
| 79 | |
} |
| 80 | |
|
| 81 | |
void afterRender(MarkupWriter writer) |
| 82 | |
{ |
| 83 | 9900 | writer.end(); |
| 84 | 9900 | } |
| 85 | |
|
| 86 | |
void inject(RenderSupport support, ComponentResources resources, String element, String clientId) |
| 87 | |
{ |
| 88 | 4 | this.renderSupport = support; |
| 89 | 4 | this.resources = resources; |
| 90 | 4 | this.element = element; |
| 91 | 4 | this.clientId = clientId; |
| 92 | 4 | } |
| 93 | |
} |