我想接收自定义组件的Value参数类型为ArrayList的值,已经创建了独立的渲染器.可是不知道怎么在自定义component类和渲染器,怎么处理?
我的标签是这样定义的.
<s:scheduleshow id="price2" value="#{vschedulebean.lstSchedules}"></s:scheduleshow>
我想要的效果是...想自定义一个控件显示数据,现在存在下列疑问:
1,数据来源于#{vschedulebean.lstSchedules},不知道定义组件类的时候是不是该继承自UIInput;
2,这个lstSchedules的类型为ArrayList<VoyageSchedule>,不知道tld文件里面是不是要配置type属性为java.util.ArrayList,也不知道在tag类里面该用什么类型接收,是object还是ArrayList;
3,三个类:自定义组件,渲染器,组件控制类之间是怎样的流程来处理ArrayList的?
如果能解答我心中的疑问的,加80分...散分!
我的标签是这样定义的.
<s:scheduleshow id="price2" value="#{vschedulebean.lstSchedules}"></s:scheduleshow>
我想要的效果是...想自定义一个控件显示数据,现在存在下列疑问:
1,数据来源于#{vschedulebean.lstSchedules},不知道定义组件类的时候是不是该继承自UIInput;
2,这个lstSchedules的类型为ArrayList<VoyageSchedule>,不知道tld文件里面是不是要配置type属性为java.util.ArrayList,也不知道在tag类里面该用什么类型接收,是object还是ArrayList;
3,三个类:自定义组件,渲染器,组件控制类之间是怎样的流程来处理ArrayList的?
如果能解答我心中的疑问的,加80分...散分!
解决方案 »
- 如何获取字段hudong_id 的值并放到表2的hudong_id里面
- 登陆后如何在没有任何操作的情况下超时注销SESSION
- Hibernate中QBC查询中createAlias与createCriteria有什么区别
- 菜鸟求助 做了一个 java web 小项目 出现大问题!!
- java票据打印
- 发布一个基于JS的仿window的JAVA CMS管理系统
- jsp+access转化为jsp+sqlserver2000,数据库连接用的用户数据源形式,不知道程序方面需要改动哪些?
- jsp调用的htm页面中文乱码?
- 怎么样在JSP中显示 WORD 或 WPS 格式的文件?
- Oracle中将2条查询产生的列,全部保存到游标中
- JSF问题: 动态表<h:dataTable>怎么能横向输出
- 服务器用tomcat,链接DB2,如何支持重链?
@Override
protected void setProperties(UIComponent component1) {
ScheduleshowComponent component=(ScheduleshowComponent) component1;
logger.info("setProperties function");
super.setProperties(component);
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ValueBinding binding = application.createValueBinding(value);
System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
component.setValueBinding("value", binding);
if (isValueReference(value)) {
component.setValueBinding("value", binding);
}
在自定义渲染器里面:写个方法(方法名自编)
private void encodeTableInLeftContainer(ResponseWriter writer,
ScheduleshowComponent fieldComponent) throws IOException {
FacesContext currentInstance = FacesContext.getCurrentInstance();
List<Voyageschedule> sss=new ArrayList<Voyageschedule>() ;
Object obj=fieldComponent.getValueBinding("value");
if (obj!= null) {
logger.info("obj!=null");
ValueBinding vb = fieldComponent.getValueBinding("value");
if (vb != null) {
logger.info("vb!=null");
sss= (List<Voyageschedule>) vb.getValue(currentInstance);
}
else
{
logger.info("vb==null");
sss=(ArrayList<Voyageschedule>) fieldComponent.getValue();
}
}
this.setLst(sss);
if(this.getLst().size()>0)
{
if (this.getLstp() != null) {
int size = this.getLstp().size();
if (size > 0) {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
.getLstp()); writer.endElement("table");
} else {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style");
writer.startElement("tr", fieldComponent);
writer.startElement("td", fieldComponent);
writer.writeAttribute("text", "/-/-/", "text");
writer.endElement("td");
writer.endElement("tr");
writer.endElement("table");
}
} else {
logger.info("this.getLst().value==null");
}
}
}
@Override
protected void setProperties(UIComponent component1) {
ScheduleshowComponent component=(ScheduleshowComponent) component1;
logger.info("setProperties function");
super.setProperties(component);
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ValueBinding binding = application.createValueBinding(value);
System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
component.setValueBinding("value", binding);
if (isValueReference(value)) {
component.setValueBinding("value", binding);
}
在自定义渲染器里面:写个方法(方法名自编)
private void encodeTableInLeftContainer(ResponseWriter writer,
ScheduleshowComponent fieldComponent) throws IOException {
FacesContext currentInstance = FacesContext.getCurrentInstance();
List<Voyageschedule> sss=new ArrayList<Voyageschedule>() ;
Object obj=fieldComponent.getValueBinding("value");
if (obj!= null) {
logger.info("obj!=null");
ValueBinding vb = fieldComponent.getValueBinding("value");
if (vb != null) {
logger.info("vb!=null");
sss= (List<Voyageschedule>) vb.getValue(currentInstance);
}
else
{
logger.info("vb==null");
sss=(ArrayList<Voyageschedule>) fieldComponent.getValue();
}
}
this.setLst(sss);
if(this.getLst().size()>0)
{
if (this.getLstp() != null) {
int size = this.getLstp().size();
if (size > 0) {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
.getLstp()); writer.endElement("table");
} else {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style");
writer.startElement("tr", fieldComponent);
writer.startElement("td", fieldComponent);
writer.writeAttribute("text", "/-/-/", "text");
writer.endElement("td");
writer.endElement("tr");
writer.endElement("table");
}
} else {
logger.info("this.getLst().value==null");
}
}
}
@Override
protected void setProperties(UIComponent component1) {
ScheduleshowComponent component=(ScheduleshowComponent) component1;
logger.info("setProperties function");
super.setProperties(component);
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ValueBinding binding = application.createValueBinding(value);
System.out.printf("setProperties class=%s expression=%s\n", binding.getType(FacesContext.getCurrentInstance()), binding.getExpressionString());
component.setValueBinding("value", binding);
if (isValueReference(value)) {
component.setValueBinding("value", binding);
}
在自定义渲染器里面:写个方法(方法名自编)
private void encodeTableInLeftContainer(ResponseWriter writer,
ScheduleshowComponent fieldComponent) throws IOException {
FacesContext currentInstance = FacesContext.getCurrentInstance();
List<Voyageschedule> sss=new ArrayList<Voyageschedule>() ;
Object obj=fieldComponent.getValueBinding("value");
if (obj!= null) {
logger.info("obj!=null");
ValueBinding vb = fieldComponent.getValueBinding("value");
if (vb != null) {
logger.info("vb!=null");
sss= (List<Voyageschedule>) vb.getValue(currentInstance);
}
else
{
logger.info("vb==null");
sss=(ArrayList<Voyageschedule>) fieldComponent.getValue();
}
}
this.setLst(sss);
if(this.getLst().size()>0)
{
if (this.getLstp() != null) {
int size = this.getLstp().size();
if (size > 0) {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style"); encodeTrInTable(writer, fieldComponent, size, this
.getLstp()); writer.endElement("table");
} else {
writer.startElement("table", fieldComponent);
String style2 = "color:#000000;background-color:#99CCFF;width:"
+ this.leftdivwidth
+ "px;height:"
+ this.containerdivheight + "px;";
writer.writeAttribute("style", style2, "style");
writer.startElement("tr", fieldComponent);
writer.startElement("td", fieldComponent);
writer.writeAttribute("text", "/-/-/", "text");
writer.endElement("td");
writer.endElement("tr");
writer.endElement("table");
}
} else {
logger.info("this.getLst().value==null");
}
}
}