Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何以编程方式更改ADF表中的样式_Java_Jdeveloper - Fatal编程技术网

Java 如何以编程方式更改ADF表中的样式

Java 如何以编程方式更改ADF表中的样式,java,jdeveloper,Java,Jdeveloper,我从数据控件生成了一个ADF表。 但是我需要改变支持bean中每个单元格的样式。 我在谷歌上找不到任何有用的东西,希望你能给我提供一些有用的信息。你能更具体一点吗?哪个jdev版本?如果您需要更改每个细胞,为什么不使用皮肤 根据这些评论,我们现在知道您使用的是JDEV11.1.2.2.0。 您可以做的是将表的styleClass属性绑定到支持bean属性。bean中的属性有一个getter和setter方法。在setter方法中,您可以从行中获取所需的所有值并进行计算。根据结果,返回适合单元格的

我从数据控件生成了一个ADF表。 但是我需要改变支持bean中每个单元格的样式。
我在谷歌上找不到任何有用的东西,希望你能给我提供一些有用的信息。

你能更具体一点吗?哪个jdev版本?如果您需要更改每个细胞,为什么不使用皮肤

根据这些评论,我们现在知道您使用的是JDEV11.1.2.2.0。 您可以做的是将表的styleClass属性绑定到支持bean属性。bean中的属性有一个getter和setter方法。在setter方法中,您可以从行中获取所需的所有值并进行计算。根据结果,返回适合单元格的样式类的名称。在应用程序的外观中定义的不同样式类。 例如,如果您在皮肤中定义以下样式类别

.high_value { background-color:green; }
.negative_value { background-color:red;}
在请求范围内的bean中,您可以从表所在的页面访问该bean

    private String styleForCell;

public String getStyleForCell()
{
    // get the value of the cell
    FacesContext lContext = FacesContext.getCurrentInstance();
    ELContext lELContext = lContext.getELContext();
    ExpressionFactory lExpressionFactory = lContext.getApplication().getExpressionFactory();
    Number val;
    val = (Number) lExpressionFactory.createValueExpression(lELContext, "#{row.valargument}", Object.class).getValue(lELContext);
    if (val == null)
        return "";

    // do the calculation and return the suitable style class
    int ival = val.intValue();
    if (ival >= 100000 )
        return "high_value";
    else if (ival < 0)
        return "negative_value";
    else 
        return "";         
}

public void setStyleForCell(String aStyleForCell)
{
    this.styleForCell = aStyleForCell;
}
现在,您可以从tables列styleClass属性以{beanname.styleForCell}的形式访问计算的样式类
这将调用列中每个单元格的方法。

您能更具体一点吗?哪个jdev版本?如果您需要更改每个细胞,为什么不使用皮肤

根据这些评论,我们现在知道您使用的是JDEV11.1.2.2.0。 您可以做的是将表的styleClass属性绑定到支持bean属性。bean中的属性有一个getter和setter方法。在setter方法中,您可以从行中获取所需的所有值并进行计算。根据结果,返回适合单元格的样式类的名称。在应用程序的外观中定义的不同样式类。 例如,如果您在皮肤中定义以下样式类别

.high_value { background-color:green; }
.negative_value { background-color:red;}
在请求范围内的bean中,您可以从表所在的页面访问该bean

    private String styleForCell;

public String getStyleForCell()
{
    // get the value of the cell
    FacesContext lContext = FacesContext.getCurrentInstance();
    ELContext lELContext = lContext.getELContext();
    ExpressionFactory lExpressionFactory = lContext.getApplication().getExpressionFactory();
    Number val;
    val = (Number) lExpressionFactory.createValueExpression(lELContext, "#{row.valargument}", Object.class).getValue(lELContext);
    if (val == null)
        return "";

    // do the calculation and return the suitable style class
    int ival = val.intValue();
    if (ival >= 100000 )
        return "high_value";
    else if (ival < 0)
        return "negative_value";
    else 
        return "";         
}

public void setStyleForCell(String aStyleForCell)
{
    this.styleForCell = aStyleForCell;
}
现在,您可以从tables列styleClass属性以{beanname.styleForCell}的形式访问计算的样式类
这将调用列中每个单元格的方法。

+1在前面的回答中。请注意,更改单元格颜色的方式在很大程度上取决于用例。如果您的用例需要动态的特殊颜色编码,那么答案就不同了,好像要求更改颜色编码以实现公司品牌一样


弗兰克回答上一个问题。请注意,更改单元格颜色的方式在很大程度上取决于用例。如果您的用例需要动态的特殊颜色编码,那么答案就不同了,好像要求更改颜色编码以实现公司品牌一样


Frank

在字段的inlineStyle中使用条件EL来根据值设置样式。
类似于{binding.value>1000?'font=bold':'font=regular'}

在字段的inlineStyle中使用条件EL来根据值设置样式。
类似于{binding.value>1000?'font=bold':'font=regular'}

我需要检查表中每个单元格的数据,如果有特定值,则该单元格中的值需要粗体和其他颜色。我在回答中概述了解决方案我需要检查表中每个单元格的数据,如果有特定值,该单元格中的值需要粗体和其他颜色。我在回答中概述了一个解决方案我需要将表中的数据与webservice中的数据进行比较。当数据不同时,该单元格的值需要粗体和红色或其他颜色。我需要将表中的数据与webservice中的数据进行比较。当数据不同时,该单元格的值需要用粗体和红色或其他颜色。问题是我不知道示例1000中的具体值。这就是为什么我需要在我的bean中这样做,因为我需要从所选行获取ID,从我的Web服务获取相应的数据,然后检查每个单元格的值,如果需要,更改样式。问题是我不知道示例1000中的特定值。这就是为什么我需要在我的bean中这样做,因为我需要从所选行获取ID,从我的Web服务获取相应的数据,然后检查每个单元格的值,如果需要,更改样式。