inputText Component BackingBean

/**
 *
 * @AppName: DöcuContent.nsf
 *  Program: InputTextComponentBackingBean.java
 *  Purpose: Create inputText items on the fly       
 *  Created: 2014.02.01.9.19.PM
 *  
 *  TODO: Add Strings to inputText items
 */

package com.dokoll.solutions.inc.Utils;

import java.util.ArrayList;
import java.util.Collection;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlPanelGrid;


/**
* @author Dököll Solutions, Inc.
* @version 2014.02.01.9.19.PM
*/

//start program
public class InputTextComponentBackingBean {
	//declare component tree variables
	//...
	//declare html formId
	private HtmlForm HtmFrm;
	//declare inputText component types
	private Collection<HtmlInputText> inputCompFirst;
	private Collection<HtmlInputText> inputCompMid;
	private Collection<HtmlInputText> inputCompLast;
	//declare inputText components repository
	private HtmlPanelGrid BaseComponentFirst;
	private HtmlPanelGrid BaseComponentMid;
	private HtmlPanelGrid BaseComponentLast;	
	//...
	//getters and setters
	public HtmlForm getHtmFrm() {
		return HtmFrm;
	}
	
	public void setHtmFrm(HtmlForm htmFrm) {
		this.HtmFrm = htmFrm;
	}

	public HtmlPanelGrid getBaseComponentFirst() {
		return BaseComponentFirst;
	}
	
	public void setBaseComponentFirst(HtmlPanelGrid baseComponentFirst) {
		this.BaseComponentFirst = baseComponentFirst;
	}

	public HtmlPanelGrid getBaseComponentMid() {
		return BaseComponentMid;
	}
	
	public void setBaseComponentMid(HtmlPanelGrid baseComponentMid) {
		this.BaseComponentMid = baseComponentMid;
	}

	public HtmlPanelGrid getBaseComponentLast() {
		return BaseComponentLast;
	}
	
	public void setBaseComponentLast(HtmlPanelGrid baseComponentLast) {
		this.BaseComponentLast = baseComponentLast;
	}

	@SuppressWarnings("unchecked")
	public InputTextComponentBackingBean() {

		//create IDs for each inputText Component
		inputCompFirst = new ArrayList<HtmlInputText>();
		for (int j = 0; j < 5; j++) {

			//plug IDs into inputText component
			HtmlInputText inputText = new HtmlInputText();
			BaseComponentFirst = new HtmlPanelGrid();
			inputText.setId("inputText1" + j);
			inputCompFirst.add(inputText);
		}
		//add component(s) to form
		BaseComponentFirst.getChildren().addAll(inputCompFirst);


		//create IDs for each inputText Component
		inputCompMid = new ArrayList<HtmlInputText>();
		for (int j = 0; j < 5; j++) {

			//plug IDs into inputText component
			HtmlInputText inputText = new HtmlInputText();
			BaseComponentMid = new HtmlPanelGrid();
			inputText.setId("inputText2" + j);
			inputCompMid.add(inputText);
		}
		//add component(s) to form
		BaseComponentMid.getChildren().addAll(inputCompMid);


		//create IDs for each inputText Component
		inputCompLast = new ArrayList<HtmlInputText>();
		for (int j = 0; j < 5; j++) {
			inputCompLast = new ArrayList<HtmlInputText>();
			//plug IDs into inputText component
			HtmlInputText inputText = new HtmlInputText();
			BaseComponentLast = new HtmlPanelGrid();
			inputText.setId("inputText3" + j);
			inputCompLast.add(inputText);
		}
		//add component(s) to form
		BaseComponentLast.getChildren().addAll(inputCompLast);

	}

	//button code
	@SuppressWarnings("unchecked")
	public void doLoadComponents() {
		int uComp = BaseComponentFirst.getChildCount();
		//send NEW inputText component to form
		HtmlInputText inputText1 = new HtmlInputText();
		inputText1.setId("inputText1" + uComp);
		BaseComponentFirst.getChildren().add(inputText1);

		//send NEW inputText component to form
		//...
		//int uComp = baseComponentMid.getChildCount();
		HtmlInputText inputText2 = new HtmlInputText();
		inputText2.setId("inputText2" + uComp);
		BaseComponentMid.getChildren().add(inputText2);

		//send NEW inputText component to form
		//...
		//int uComp = baseComponentLast.getChildCount();
		HtmlInputText inputText3 = new HtmlInputText();
		inputText3.setId("inputText3" + uComp);
		BaseComponentLast.getChildren().add(inputText3);
	}

}





Grab this XSnippet, include it in your application to load inputText items to your Xpages form @ will, no 'Strings attached'...  Please see Xpages file for additional instructions...

Java
Köll S Cherizard
February 1, 2014 9:47 PM
Rating
5

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...