package com.yinhe.iei.common; import java.util.Random; import javax.faces.application.Application; import javax.faces.component.html.HtmlInputText; import javax.faces.component.html.HtmlOutputText; import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; public class UICreateXY ... {public static Application app=FacesContext.getCurrentInstance().getApplication();public static HtmlInputText createinputtext(String id,String bindingstr,String var)...{ //Application app=FacesContext.getCurrentInstance().getApplication(); HtmlInputText hit=(HtmlInputText)app.createComponent(HtmlInputText.COMPONENT_TYPE); hit.setId(id); if(!bindingstr.equals("")) ...{ ValueBinding vb=app.createValueBinding(bindingstr); hit.setValueBinding("value", vb); } if(var!=null&&!var.equals("")) ...{ hit.setValue(var); } return hit;}public static HtmlOutputText createoutputtext(String var)...{ //Application app=FacesContext.getCurrentInstance().getApplication(); HtmlOutputText hot=(HtmlOutputText)app.createComponent(HtmlOutputText.COMPONENT_TYPE); hot.setValue(var); Random rd=new Random(); long lg=rd.nextLong(); hot.setId("htmloutputtext"+lg); return hot;}public static HtmlPanelGroup createpanelgroup(String id)...{ HtmlPanelGroup hpg=(HtmlPanelGroup)app.createComponent(HtmlPanelGroup.COMPONENT_TYPE); hpg.setId(id); return hpg;}}