/** {@inheritDoc} */ @Override protected UIInput createInput(final PropertyDescriptor<P, E> property, final RenderContext context) { final HtmlInputText input = new HtmlInputText(); input.setStyleClass(context.resolveStyleClass(JsfStyleClasses.FORM_INPUT_TEXT)); return input; }
private String inputValue; //setter() getter() UIInput input = new HtmlInputText(); @PostCostruct public void addInput() { // your previos create and add input fields to the form + setting value expression Application app = FacesContext.getCurrentInstance().getApplication(); input.setValueExpression("value",app.getExpressionFactory().createValueExpression( FacesContext.getCurrentInstance().getELContext(), "#{bean.inputValue}", String.class)); }
UIInput input = new HtmlInputText(); input.setId("input1"); input.setValueExpression("value", createValueExpression("#{bean.input1}", String.class)); form.getChildren().add(input);
/** Request scope bean defined in faces-config.xml */ public class ComponentMakerBean { private UIPanel panel; public UIPanel getPanel() { if(panel == null) { panel = new HtmlPanelGroup(); for(int i=0; i<3; i++) { panel.getChildren().add(new HtmlInputText()); } } return panel; } public void setPanel(UIPanel panel) { this.panel = panel; } public String dumpValuesAction() { for(Object kid : panel.getChildren()) { if(kid instanceof ValueHolder) { ValueHolder valueHolder = (ValueHolder) kid; System.out.println(valueHolder.getValue()); } } return null; //no navigation } }
values.put(key,"newValue"); HtmlInputText input = new HtmlInputText();
public HtmlInputText getNameEnInputComponent() { if (this.nameEnInputComponent == null) { this.nameEnInputComponent = new HtmlInputText(); ExecutionYear executionYear = (getSelectedExecutionYear() != null) ? getSelectedExecutionYear() : ExecutionYear.readCurrentExecutionYear(); final DegreeInfo degreeInfo = getDegreeInfo(executionYear); this.nameEnInputComponent.setValue(degreeInfo.getName().getContent(org.fenixedu.academic.util.LocaleUtils.EN)); } return this.nameEnInputComponent; }
@PostConstruct public void init() { HtmlInputText hit = new HtmlInputText(); // properties are easy: hol.setStyle("border: 2px solid red"); // binding is a bit harder: hit.setValueExpression("value", expression("#{test.counter}", String.class)); HtmlOutcomeTargetLink hol = new HtmlOutcomeTargetLink(); hol.setValue("link leading to another view"); hol.setOutcome("whatever"); component = new UIPanel(); component.getChildren().add(hit); component.getChildren().add(hol); } private ValueExpression expression(String s, Class c){ return FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression( FacesContext.getCurrentInstance().getELContext(), s, c ); }
public HtmlInputText getNameInputComponent() { if (this.nameInputComponent == null) { this.nameInputComponent = new HtmlInputText(); ExecutionYear executionYear = (getSelectedExecutionYear() != null) ? getSelectedExecutionYear() : ExecutionYear.readCurrentExecutionYear(); DegreeInfo degreeInfo = getDegreeInfo(executionYear); setSelectedExecutionYearId(degreeInfo.getExecutionYear().getExternalId()); this.nameInputComponent.setValue(degreeInfo.getName().getContent(org.fenixedu.academic.util.LocaleUtils.PT)); } return this.nameInputComponent; }
@Override public UIInput createInput() { HtmlInputText input = new HtmlInputText(); LengthValidator validator = new LengthValidator(); if (getMaxLenght() != null) { input.setSize(getMaxLenght()); input.setMaxlength(getMaxLenght()); validator.setMaximum(getMaxLenght()); } validator.setMinimum(getMinLenght()); input.addValidator(validator); return input; }
HtmlInputText inputUser = new HtmlInputText(); inputUser.setId(USER_NAME); inputUser.setMaxlength(User.USERNAME_MAX_LENGHT);
protected void setUp() throws Exception { this.jsfMock.setUp(); this.jsfMock.facesContext().getApplication().setViewHandler(new MockViewHandler()); this.jsfMock.facesContext().setResponseWriter(new MockResponseWriter(this.output, null, null)); UIViewRoot viewToRender = new UIViewRoot(); viewToRender.setRenderKitId("HTML_BASIC"); viewToRender.setViewId(VIEW_ID); this.jsfMock.facesContext().setViewRoot(viewToRender); UIForm form = new HtmlForm(); form.setId("myForm"); UIInput input = new HtmlInputText(); input.setId("foo"); form.getChildren().add(input); viewToRender.getChildren().add(form); RequestContextHolder.setRequestContext(this.context); EasyMock.expect(this.context.getExternalContext()).andStubReturn(this.extContext); EasyMock.expect(this.context.getFlashScope()).andStubReturn(this.flashScope); EasyMock.expect(this.context.getFlowScope()).andStubReturn(this.flowMap); EasyMock.expect(this.context.getFlowExecutionContext()).andStubReturn(this.flowExecutionContext); EasyMock.expect(this.flowExecutionContext.getKey()).andStubReturn(this.key); this.view = new JsfView(viewToRender, this.jsfMock.lifecycle(), this.context); }