jsf自定义组件-jafyear选择年份

本文介绍了一个用于Java EE项目的年份选择框组件,该组件允许用户从指定范围中选择年份,并支持使用当前年份作为基准进行简单表达式的配置。

 

就是一个下拉框,可以配置选取的范围,用today表示当期年份,输入简单表达式。 

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

/**
 * 年份选择框组件
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:28
 
*/

public class JafYear extends UIComponentBase {
    
    
public final String JAF_DATE_FAMILY = "jaf.jafdate";

    
public String getFamily() {
        
return JAF_DATE_FAMILY;
    }

    
    
public Object saveState(FacesContext context) {
        Object values[] 
= new Object[1];
        values[
0= super.saveState(context);
        
return values;
    }


    
public void restoreState(FacesContext context, Object state) {
        Object values[] 
= (Object[]) state;
        
super.restoreState(context, values[0]);

    }


}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;

import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;

/**
 * 年份选择框组件renderer
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:30
 
*/

public class JafYearRenderer extends HtmlRenderer {

    
public void encodeEnd(FacesContext facesContext, UIComponent component)
            
throws IOException {
        
        String sfrom 
= (String) component.getAttributes().get("from");
        String sto 
= (String) component.getAttributes().get("to");
        
int ifrom = convert(sfrom) + 1900;
        
int ito = convert(sto) + 1900;
        ResponseWriter writer 
= facesContext.getResponseWriter();
        String clientId 
= component.getClientId(facesContext);
        
        
        ValueBinding vb 
= component.getValueBinding("value");
        String syear 
= (String) vb.getValue(facesContext);
        
if(syear == null)
        
{
            syear 
= "" + (new Date().getYear() + 1900 );
        }

        
        
int year = Integer.parseInt(syear);

        writer.write(
"" + clientId + "" name="" + clientId + ""> ");
        
for (int i = ifrom; i <= ito; i++{
            writer.write(
"" + i + """);
            
if(year == i)
            
{
                writer.write(
" selected ");
            }

            writer.write(
">" + i );
            writer.write(
"");
        }

        writer.write(
"");
    }

    
    
public void decode(FacesContext facesContext, UIComponent uiComponent)
    
{
        Map paramMap 
= facesContext.getExternalContext()
        .getRequestParameterMap();
        String clientId 
= uiComponent.getClientId(facesContext);
        
if(paramMap.containsKey(clientId))
        
{
            String value 
= (String) paramMap
                    .get(clientId);
            
            ValueBinding vb 
= uiComponent.getValueBinding("value");
            vb.setValue(facesContext, value);
            System.out.println(clientId 
+ " value is: " + value);
        }

    }


    
private int convert(String exp) {

        
boolean bflagt = false;
        
boolean bflags = false;

        String ex 
= exp.replaceAll(" """);
        
if (ex.startsWith("today")) {
            bflagt 
= true;
            ex 
= ex.replaceAll("today""");
        }

        
        
if (ex.startsWith("+")) {
            bflags 
= true;
        }

        
        ex 
= ex.substring(1, ex.length());

        
int rvalue = Integer.parseInt(ex);
        
if(!bflags)
        
{
            rvalue 
= - rvalue;
        }


        
if (bflagt)
            rvalue 
= rvalue + new Date().getYear();

        
return rvalue;
    }

}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;

/**
 * 年份选择框组件的标签
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:36
 
*/

public class JafYearTag extends UIComponentTag
{
    
    
public String getComponentType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear";
    }


    
public String getRendererType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer";
    }

    
    
private String from;
    
private String to;
    
private String value;
    
    
public String getValue() {
        
return value;
    }


    
public void setValue(String value) {
        
this.value = value;
    }


    
public String getFrom() {
        
return from;
    }


    
public void setFrom(String from) {
        
this.from = from;
    }


    
public String getTo() {
        
return to;
    }


    
public void setTo(String to) {
        
this.to = to;
    }

    
    
public void setProperties(UIComponent component) {
        
super.setProperties(component);
        setStringProperty(component, 
"from", from);
        setStringProperty(component, 
"to", to);
        setStringProperty(component, 
"value", value);
    }


    
private void setStringProperty(UIComponent component, String attrName,
            String attrValue) 
{
        
if (attrValue == null)
            
return;
        
if (isValueReference(attrValue)) {
            FacesContext context 
= FacesContext.getCurrentInstance();
            Application application 
= context.getApplication();
            ValueBinding binding 
= application.createValueBinding(attrValue);
            component.setValueBinding(attrName, binding);
        }
 else {
            component.getAttributes().put(attrName, attrValue);
        }

    }


    
public void release() {
        
super.release();
        from 
= null;
        to  
= null;
        value 
= null;
    }

    
    
}

 

 

<tag>
        
<name>jafyear</name>
        
<tag-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearTag
        
</tag-class>
        
<body-content>empty</body-content>
        
<attribute>
            
<name>from</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>to</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>value</name>
            
<required>true</required>
        
</attribute>
    
</tag>

 

<renderer>
            
<component-family>jaf.jafdate</component-family>
            
<renderer-type>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-type>
            
<renderer-class>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-class>
        
</renderer>

    
<component>
        
<component-type>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-type>
        
<component-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-class>
    
</component>



 

就是一个下拉框,可以配置选取的范围,用today表示当期年份,输入简单表达式。 

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

/**
 * 年份选择框组件
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:28
 
*/

public class JafYear extends UIComponentBase {
    
    
public final String JAF_DATE_FAMILY = "jaf.jafdate";

    
public String getFamily() {
        
return JAF_DATE_FAMILY;
    }

    
    
public Object saveState(FacesContext context) {
        Object values[] 
= new Object[1];
        values[
0= super.saveState(context);
        
return values;
    }


    
public void restoreState(FacesContext context, Object state) {
        Object values[] 
= (Object[]) state;
        
super.restoreState(context, values[0]);

    }


}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;

import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;

/**
 * 年份选择框组件renderer
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:30
 
*/

public class JafYearRenderer extends HtmlRenderer {

    
public void encodeEnd(FacesContext facesContext, UIComponent component)
            
throws IOException {
        
        String sfrom 
= (String) component.getAttributes().get("from");
        String sto 
= (String) component.getAttributes().get("to");
        
int ifrom = convert(sfrom) + 1900;
        
int ito = convert(sto) + 1900;
        ResponseWriter writer 
= facesContext.getResponseWriter();
        String clientId 
= component.getClientId(facesContext);
        
        
        ValueBinding vb 
= component.getValueBinding("value");
        String syear 
= (String) vb.getValue(facesContext);
        
if(syear == null)
        
{
            syear 
= "" + (new Date().getYear() + 1900 );
        }

        
        
int year = Integer.parseInt(syear);

        writer.write(
"" + clientId + "" name="" + clientId + ""> ");
        
for (int i = ifrom; i <= ito; i++{
            writer.write(
"" + i + """);
            
if(year == i)
            
{
                writer.write(
" selected ");
            }

            writer.write(
">" + i );
            writer.write(
"");
        }

        writer.write(
"");
    }

    
    
public void decode(FacesContext facesContext, UIComponent uiComponent)
    
{
        Map paramMap 
= facesContext.getExternalContext()
        .getRequestParameterMap();
        String clientId 
= uiComponent.getClientId(facesContext);
        
if(paramMap.containsKey(clientId))
        
{
            String value 
= (String) paramMap
                    .get(clientId);
            
            ValueBinding vb 
= uiComponent.getValueBinding("value");
            vb.setValue(facesContext, value);
            System.out.println(clientId 
+ " value is: " + value);
        }

    }


    
private int convert(String exp) {

        
boolean bflagt = false;
        
boolean bflags = false;

        String ex 
= exp.replaceAll(" """);
        
if (ex.startsWith("today")) {
            bflagt 
= true;
            ex 
= ex.replaceAll("today""");
        }

        
        
if (ex.startsWith("+")) {
            bflags 
= true;
        }

        
        ex 
= ex.substring(1, ex.length());

        
int rvalue = Integer.parseInt(ex);
        
if(!bflags)
        
{
            rvalue 
= - rvalue;
        }


        
if (bflagt)
            rvalue 
= rvalue + new Date().getYear();

        
return rvalue;
    }

}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;

/**
 * 年份选择框组件的标签
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:36
 
*/

public class JafYearTag extends UIComponentTag
{
    
    
public String getComponentType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear";
    }


    
public String getRendererType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer";
    }

    
    
private String from;
    
private String to;
    
private String value;
    
    
public String getValue() {
        
return value;
    }


    
public void setValue(String value) {
        
this.value = value;
    }


    
public String getFrom() {
        
return from;
    }


    
public void setFrom(String from) {
        
this.from = from;
    }


    
public String getTo() {
        
return to;
    }


    
public void setTo(String to) {
        
this.to = to;
    }

    
    
public void setProperties(UIComponent component) {
        
super.setProperties(component);
        setStringProperty(component, 
"from", from);
        setStringProperty(component, 
"to", to);
        setStringProperty(component, 
"value", value);
    }


    
private void setStringProperty(UIComponent component, String attrName,
            String attrValue) 
{
        
if (attrValue == null)
            
return;
        
if (isValueReference(attrValue)) {
            FacesContext context 
= FacesContext.getCurrentInstance();
            Application application 
= context.getApplication();
            ValueBinding binding 
= application.createValueBinding(attrValue);
            component.setValueBinding(attrName, binding);
        }
 else {
            component.getAttributes().put(attrName, attrValue);
        }

    }


    
public void release() {
        
super.release();
        from 
= null;
        to  
= null;
        value 
= null;
    }

    
    
}

 

 

<tag>
        
<name>jafyear</name>
        
<tag-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearTag
        
</tag-class>
        
<body-content>empty</body-content>
        
<attribute>
            
<name>from</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>to</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>value</name>
            
<required>true</required>
        
</attribute>
    
</tag>

 

<renderer>
            
<component-family>jaf.jafdate</component-family>
            
<renderer-type>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-type>
            
<renderer-class>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-class>
        
</renderer>

    
<component>
        
<component-type>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-type>
        
<component-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-class>
    
</component>



 

就是一个下拉框,可以配置选取的范围,用today表示当期年份,输入简单表达式。 

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

/**
 * 年份选择框组件
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:28
 
*/

public class JafYear extends UIComponentBase {
    
    
public final String JAF_DATE_FAMILY = "jaf.jafdate";

    
public String getFamily() {
        
return JAF_DATE_FAMILY;
    }

    
    
public Object saveState(FacesContext context) {
        Object values[] 
= new Object[1];
        values[
0= super.saveState(context);
        
return values;
    }


    
public void restoreState(FacesContext context, Object state) {
        Object values[] 
= (Object[]) state;
        
super.restoreState(context, values[0]);

    }


}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;

import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;

/**
 * 年份选择框组件renderer
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:30
 
*/

public class JafYearRenderer extends HtmlRenderer {

    
public void encodeEnd(FacesContext facesContext, UIComponent component)
            
throws IOException {
        
        String sfrom 
= (String) component.getAttributes().get("from");
        String sto 
= (String) component.getAttributes().get("to");
        
int ifrom = convert(sfrom) + 1900;
        
int ito = convert(sto) + 1900;
        ResponseWriter writer 
= facesContext.getResponseWriter();
        String clientId 
= component.getClientId(facesContext);
        
        
        ValueBinding vb 
= component.getValueBinding("value");
        String syear 
= (String) vb.getValue(facesContext);
        
if(syear == null)
        
{
            syear 
= "" + (new Date().getYear() + 1900 );
        }

        
        
int year = Integer.parseInt(syear);

        writer.write(
"" + clientId + "" name="" + clientId + ""> ");
        
for (int i = ifrom; i <= ito; i++{
            writer.write(
"" + i + """);
            
if(year == i)
            
{
                writer.write(
" selected ");
            }

            writer.write(
">" + i );
            writer.write(
"");
        }

        writer.write(
"");
    }

    
    
public void decode(FacesContext facesContext, UIComponent uiComponent)
    
{
        Map paramMap 
= facesContext.getExternalContext()
        .getRequestParameterMap();
        String clientId 
= uiComponent.getClientId(facesContext);
        
if(paramMap.containsKey(clientId))
        
{
            String value 
= (String) paramMap
                    .get(clientId);
            
            ValueBinding vb 
= uiComponent.getValueBinding("value");
            vb.setValue(facesContext, value);
            System.out.println(clientId 
+ " value is: " + value);
        }

    }


    
private int convert(String exp) {

        
boolean bflagt = false;
        
boolean bflags = false;

        String ex 
= exp.replaceAll(" """);
        
if (ex.startsWith("today")) {
            bflagt 
= true;
            ex 
= ex.replaceAll("today""");
        }

        
        
if (ex.startsWith("+")) {
            bflags 
= true;
        }

        
        ex 
= ex.substring(1, ex.length());

        
int rvalue = Integer.parseInt(ex);
        
if(!bflags)
        
{
            rvalue 
= - rvalue;
        }


        
if (bflagt)
            rvalue 
= rvalue + new Date().getYear();

        
return rvalue;
    }

}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;

/**
 * 年份选择框组件的标签
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:36
 
*/

public class JafYearTag extends UIComponentTag
{
    
    
public String getComponentType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear";
    }


    
public String getRendererType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer";
    }

    
    
private String from;
    
private String to;
    
private String value;
    
    
public String getValue() {
        
return value;
    }


    
public void setValue(String value) {
        
this.value = value;
    }


    
public String getFrom() {
        
return from;
    }


    
public void setFrom(String from) {
        
this.from = from;
    }


    
public String getTo() {
        
return to;
    }


    
public void setTo(String to) {
        
this.to = to;
    }

    
    
public void setProperties(UIComponent component) {
        
super.setProperties(component);
        setStringProperty(component, 
"from", from);
        setStringProperty(component, 
"to", to);
        setStringProperty(component, 
"value", value);
    }


    
private void setStringProperty(UIComponent component, String attrName,
            String attrValue) 
{
        
if (attrValue == null)
            
return;
        
if (isValueReference(attrValue)) {
            FacesContext context 
= FacesContext.getCurrentInstance();
            Application application 
= context.getApplication();
            ValueBinding binding 
= application.createValueBinding(attrValue);
            component.setValueBinding(attrName, binding);
        }
 else {
            component.getAttributes().put(attrName, attrValue);
        }

    }


    
public void release() {
        
super.release();
        from 
= null;
        to  
= null;
        value 
= null;
    }

    
    
}

 

 

<tag>
        
<name>jafyear</name>
        
<tag-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearTag
        
</tag-class>
        
<body-content>empty</body-content>
        
<attribute>
            
<name>from</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>to</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>value</name>
            
<required>true</required>
        
</attribute>
    
</tag>

 

<renderer>
            
<component-family>jaf.jafdate</component-family>
            
<renderer-type>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-type>
            
<renderer-class>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-class>
        
</renderer>

    
<component>
        
<component-type>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-type>
        
<component-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-class>
    
</component>



 

就是一个下拉框,可以配置选取的范围,用today表示当期年份,输入简单表达式。 

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

/**
 * 年份选择框组件
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:28
 
*/

public class JafYear extends UIComponentBase {
    
    
public final String JAF_DATE_FAMILY = "jaf.jafdate";

    
public String getFamily() {
        
return JAF_DATE_FAMILY;
    }

    
    
public Object saveState(FacesContext context) {
        Object values[] 
= new Object[1];
        values[
0= super.saveState(context);
        
return values;
    }


    
public void restoreState(FacesContext context, Object state) {
        Object values[] 
= (Object[]) state;
        
super.restoreState(context, values[0]);

    }


}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;

import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;

/**
 * 年份选择框组件renderer
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:30
 
*/

public class JafYearRenderer extends HtmlRenderer {

    
public void encodeEnd(FacesContext facesContext, UIComponent component)
            
throws IOException {
        
        String sfrom 
= (String) component.getAttributes().get("from");
        String sto 
= (String) component.getAttributes().get("to");
        
int ifrom = convert(sfrom) + 1900;
        
int ito = convert(sto) + 1900;
        ResponseWriter writer 
= facesContext.getResponseWriter();
        String clientId 
= component.getClientId(facesContext);
        
        
        ValueBinding vb 
= component.getValueBinding("value");
        String syear 
= (String) vb.getValue(facesContext);
        
if(syear == null)
        
{
            syear 
= "" + (new Date().getYear() + 1900 );
        }

        
        
int year = Integer.parseInt(syear);

        writer.write(
"" + clientId + "" name="" + clientId + ""> ");
        
for (int i = ifrom; i <= ito; i++{
            writer.write(
"" + i + """);
            
if(year == i)
            
{
                writer.write(
" selected ");
            }

            writer.write(
">" + i );
            writer.write(
"");
        }

        writer.write(
"");
    }

    
    
public void decode(FacesContext facesContext, UIComponent uiComponent)
    
{
        Map paramMap 
= facesContext.getExternalContext()
        .getRequestParameterMap();
        String clientId 
= uiComponent.getClientId(facesContext);
        
if(paramMap.containsKey(clientId))
        
{
            String value 
= (String) paramMap
                    .get(clientId);
            
            ValueBinding vb 
= uiComponent.getValueBinding("value");
            vb.setValue(facesContext, value);
            System.out.println(clientId 
+ " value is: " + value);
        }

    }


    
private int convert(String exp) {

        
boolean bflagt = false;
        
boolean bflags = false;

        String ex 
= exp.replaceAll(" """);
        
if (ex.startsWith("today")) {
            bflagt 
= true;
            ex 
= ex.replaceAll("today""");
        }

        
        
if (ex.startsWith("+")) {
            bflags 
= true;
        }

        
        ex 
= ex.substring(1, ex.length());

        
int rvalue = Integer.parseInt(ex);
        
if(!bflags)
        
{
            rvalue 
= - rvalue;
        }


        
if (bflagt)
            rvalue 
= rvalue + new Date().getYear();

        
return rvalue;
    }

}

 

package com.cfcc.jaf.webx.component.jafdate.jafyear;

import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;

/**
 * 年份选择框组件的标签
 * 
@author qinjinwei
 * $date 2007-9-12 上午09:52:36
 
*/

public class JafYearTag extends UIComponentTag
{
    
    
public String getComponentType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear";
    }


    
public String getRendererType()
    
{
        
return "com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer";
    }

    
    
private String from;
    
private String to;
    
private String value;
    
    
public String getValue() {
        
return value;
    }


    
public void setValue(String value) {
        
this.value = value;
    }


    
public String getFrom() {
        
return from;
    }


    
public void setFrom(String from) {
        
this.from = from;
    }


    
public String getTo() {
        
return to;
    }


    
public void setTo(String to) {
        
this.to = to;
    }

    
    
public void setProperties(UIComponent component) {
        
super.setProperties(component);
        setStringProperty(component, 
"from", from);
        setStringProperty(component, 
"to", to);
        setStringProperty(component, 
"value", value);
    }


    
private void setStringProperty(UIComponent component, String attrName,
            String attrValue) 
{
        
if (attrValue == null)
            
return;
        
if (isValueReference(attrValue)) {
            FacesContext context 
= FacesContext.getCurrentInstance();
            Application application 
= context.getApplication();
            ValueBinding binding 
= application.createValueBinding(attrValue);
            component.setValueBinding(attrName, binding);
        }
 else {
            component.getAttributes().put(attrName, attrValue);
        }

    }


    
public void release() {
        
super.release();
        from 
= null;
        to  
= null;
        value 
= null;
    }

    
    
}

 

 

<tag>
        
<name>jafyear</name>
        
<tag-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearTag
        
</tag-class>
        
<body-content>empty</body-content>
        
<attribute>
            
<name>from</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>to</name>
            
<required>true</required>
        
</attribute>
        
<attribute>
            
<name>value</name>
            
<required>true</required>
        
</attribute>
    
</tag>

 

<renderer>
            
<component-family>jaf.jafdate</component-family>
            
<renderer-type>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-type>
            
<renderer-class>com.cfcc.jaf.webx.component.jafdate.jafyear.JafYearRenderer</renderer-class>
        
</renderer>

    
<component>
        
<component-type>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-type>
        
<component-class>
            com.cfcc.jaf.webx.component.jafdate.jafyear.JafYear
        
</component-class>
    
</component>



内容概要:本文围绕新一代传感器产品在汽车电子电气架构中的关键作用展开分析,重点探讨了智能汽车向高阶智能化演进背景下,传统传感器无法满足感知需求的问题。文章系统阐述了自动驾驶、智能座舱、电动化与网联化三大趋势对传感器技术提出的更高要求,并深入剖析了激光雷达、4D毫米波雷达和3D-ToF摄像头三类核心新型传感器的技术原理、性能优势与现存短板。激光雷达凭借高精度三维点云成为高阶智驾的“眼睛”,4D毫米波雷达通过增加高度维度提升环境感知能力,3D-ToF摄像头则在智能座舱中实现人体姿态识别与交互功能。文章还指出传感器正从单一数据采集向智能决策升级,强调车规级可靠性、多模态融合与成本控制是未来发展方向。; 适合人群:从事汽车电子、智能驾驶、传感器研发等相关领域的工程师和技术管理人员,具备一定专业背景的研发人员;; 使用场景及目标:①理解新一代传感器在智能汽车系统中的定位与技术差异;②掌握激光雷达、4D毫米波雷达、3D-ToF摄像头的核心参数、应用场景及选型依据;③为智能驾驶感知层设计、多传感器融合方案提供理论支持与技术参考; 阅读建议:建议结合实际项目需求对比各类传感器性能指标,关注其在复杂工况下的鲁棒性表现,并重视传感器与整车系统的集成适配问题,同时跟踪芯片化、固态化等技术演进趋势。
内容概要:本文系统阐述了汽车电子软件测试的整体框架,重点围绕软件及系统集成测试、软件与系统(需求)测试、验收测试、测试报告编写以及整体测试状态汇总五大核心环节展开。详细说明了软件集成测试与系统集成测试在组件聚合、软硬协同、接口验证等方面的实施策略与技术差异,明确了软件测试偏重逻辑正确性(白盒)、系统测试关注端到端行为表现(黑盒)的定位区分,并强调验收测试正从工程交付关口转变为用户价值验证的核心环节。同时,文章指出测试报告需建立需求与用例间的可追溯链,整体测试状态汇总则是呈现软件质量全景的“仪表盘”,对于多域协同的复杂汽车系统至关重要。; 适合人群:从事汽车电子、嵌入式系统开发与测试的工程师,尤其是工作1-3年、希望深入理解软件测试体系与流程的中初级技术人员;也适用于项目管理人员和技术负责人; 使用场景及目标:①理解汽车软件测试各阶段的边界、职责与协作关系;②掌握集成测试中软/硬件接口验证的方法论;③构建从技术测试到用户价值验证的全局视角,提升测试策略设计能力; 阅读建议:此资源以工程实践为基础,结合ASPICE等标准演进,不仅讲解测试技术细节,更强调测试管理与用户思维的融合,建议结合实际项目流程对照学习,并关注各测试层级之间的衔接与追溯机制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值