| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.corelib.pages; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.FieldTranslator; |
| 18 | |
import org.apache.tapestry5.FieldValidator; |
| 19 | |
import org.apache.tapestry5.SelectModel; |
| 20 | |
import org.apache.tapestry5.ValueEncoder; |
| 21 | |
import org.apache.tapestry5.annotations.Component; |
| 22 | |
import org.apache.tapestry5.annotations.Environmental; |
| 23 | |
import org.apache.tapestry5.corelib.components.*; |
| 24 | |
import org.apache.tapestry5.services.BeanBlockContribution; |
| 25 | |
import org.apache.tapestry5.services.BeanBlockSource; |
| 26 | |
import org.apache.tapestry5.services.PropertyEditContext; |
| 27 | |
import org.apache.tapestry5.util.EnumSelectModel; |
| 28 | |
import org.apache.tapestry5.util.EnumValueEncoder; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 8 | public class PropertyEditBlocks |
| 38 | |
{ |
| 39 | |
@Environmental |
| 40 | |
private PropertyEditContext context; |
| 41 | |
|
| 42 | |
@Component( |
| 43 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", |
| 44 | |
"translate=prop:textFieldTranslator", "validate=prop:textFieldValidator", |
| 45 | |
"clientId=prop:context.propertyId", "annotationProvider=context"}) |
| 46 | |
private TextField textField; |
| 47 | |
|
| 48 | |
@Component( |
| 49 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", |
| 50 | |
"translate=prop:numberFieldTranslator", "validate=prop:numberFieldValidator", |
| 51 | |
"clientId=prop:context.propertyId", "annotationProvider=context"}) |
| 52 | |
private TextField numberField; |
| 53 | |
|
| 54 | |
|
| 55 | |
@Component( |
| 56 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", "encoder=valueEncoderForProperty", |
| 57 | |
"model=selectModelForProperty", "validate=prop:selectValidator", |
| 58 | |
"clientId=prop:context.propertyId"}) |
| 59 | |
private Select select; |
| 60 | |
|
| 61 | |
@SuppressWarnings("unused") |
| 62 | |
@Component( |
| 63 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", |
| 64 | |
"clientId=prop:context.propertyId"}) |
| 65 | |
private Checkbox checkboxField; |
| 66 | |
|
| 67 | |
@SuppressWarnings("unused") |
| 68 | |
@Component( |
| 69 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", "clientId=prop:context.propertyid", |
| 70 | |
"validate=prop:dateFieldValidator"}) |
| 71 | |
private DateField dateField; |
| 72 | |
|
| 73 | |
@Component( |
| 74 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", |
| 75 | |
"translate=prop:passwordFieldTranslator", "validate=prop:passwordFieldValidator", |
| 76 | |
"clientId=prop:context.propertyId", "annotationProvider=context"}) |
| 77 | |
private PasswordField passwordField; |
| 78 | |
|
| 79 | |
@Component( |
| 80 | |
parameters = {"value=context.propertyValue", "label=prop:context.label", |
| 81 | |
"translate=prop:textAreaTranslator", |
| 82 | |
"validate=prop:textAreaValidator", "clientId=prop:context.propertyId", |
| 83 | |
"annotationProvider=context"}) |
| 84 | |
private TextArea textArea; |
| 85 | |
|
| 86 | |
|
| 87 | |
public PropertyEditContext getContext() |
| 88 | |
{ |
| 89 | 1360 | return context; |
| 90 | |
} |
| 91 | |
|
| 92 | |
|
| 93 | |
public FieldTranslator getTextFieldTranslator() |
| 94 | |
{ |
| 95 | 124 | return context.getTranslator(textField); |
| 96 | |
} |
| 97 | |
|
| 98 | |
public FieldValidator getTextFieldValidator() |
| 99 | |
{ |
| 100 | 124 | return context.getValidator(textField); |
| 101 | |
} |
| 102 | |
|
| 103 | |
public FieldTranslator getNumberFieldTranslator() |
| 104 | |
{ |
| 105 | 84 | return context.getTranslator(numberField); |
| 106 | |
} |
| 107 | |
|
| 108 | |
public FieldValidator getNumberFieldValidator() |
| 109 | |
{ |
| 110 | 84 | return context.getValidator(numberField); |
| 111 | |
} |
| 112 | |
|
| 113 | |
public FieldTranslator getPasswordFieldTranslator() |
| 114 | |
{ |
| 115 | 60 | return context.getTranslator(passwordField); |
| 116 | |
} |
| 117 | |
|
| 118 | |
public FieldValidator getPasswordFieldValidator() |
| 119 | |
{ |
| 120 | 60 | return context.getValidator(passwordField); |
| 121 | |
} |
| 122 | |
|
| 123 | |
public FieldTranslator getTextAreaTranslator() |
| 124 | |
{ |
| 125 | 32 | return context.getTranslator(textArea); |
| 126 | |
} |
| 127 | |
|
| 128 | |
public FieldValidator getTextAreaValidator() |
| 129 | |
{ |
| 130 | 32 | return context.getValidator(textArea); |
| 131 | |
} |
| 132 | |
|
| 133 | |
|
| 134 | |
public FieldValidator getDateFieldValidator() |
| 135 | |
{ |
| 136 | 6 | return context.getValidator(dateField); |
| 137 | |
} |
| 138 | |
|
| 139 | |
public FieldValidator getSelectValidator() |
| 140 | |
{ |
| 141 | 38 | return context.getValidator(select); |
| 142 | |
} |
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
@SuppressWarnings("unchecked") |
| 148 | |
public ValueEncoder getValueEncoderForProperty() |
| 149 | |
{ |
| 150 | 38 | return new EnumValueEncoder(context.getPropertyType()); |
| 151 | |
} |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
@SuppressWarnings("unchecked") |
| 157 | |
public SelectModel getSelectModelForProperty() |
| 158 | |
{ |
| 159 | 26 | return new EnumSelectModel(context.getPropertyType(), context.getContainerMessages()); |
| 160 | |
} |
| 161 | |
} |