How to change the font color of a particular row in af:table

I have a <af:table> bounded to a readonly ViewObject and this view object is a collection of an sql query. Now when this table is rendered i want font color of the specific attributes to be changed based on certain logic.
Eg. If my af:table is showing a resultset which has Attributest like ... EmployeeName | BalanceLeave . Then i want that the BalanceLeave value shoud be displayed in RED color if leave balance attribute value is more than 20.
Please help me on this.

For this you use the styleClass property of the attribute and use an EL bound to a managed bean to return the desired style.
Something like this to switch the color public class ColorSwitchBean {
    public ColorSwitchBean() {
        super();
    String mStyleClass = null;
String mColorSyle = null;
    public String getStyleClass() {
        FacesContext fc = FacesContext.getCurrentInstance();
        ELContext elc = fc.getELContext();
        ExpressionFactory elf = fc.getApplication().getExpressionFactory();
        String sval =
            (String)elf.createValueExpression(elc, "#{row.City}", Object.class).getValue(elc);
        if (sval.startsWith("S"))
            mStyleClass = "red_background";
        else if (sval.startsWith("M"))
            mStyleClass = "green_background";
        else
            mStyleClass="";
        return mStyleClass;
     public void setStyleClass(String aStyleClass) {
        mStyleClass = aStyleClass;
    public void setColorSyle(String mColorSyle) {
        this.mColorSyle = mColorSyle;
    public String getColorSyle() {
      FacesContext fc = FacesContext.getCurrentInstance();
      ELContext elc = fc.getELContext();
      ExpressionFactory elf = fc.getApplication().getExpressionFactory();
      String sval =
          (String)elf.createValueExpression(elc, "#{row.City}", Object.class).getValue(elc);
      mColorSyle = "";
      if (sval.startsWith("S")) {
          mColorSyle = "background-color:Red";
      else if (sval.startsWith("M")) {
          mColorSyle = "background-color:Green";
      return mColorSyle;
}and this inside the table:- <af:column sortProperty="City" sortable="true" headerText="#{bindings.Departments.hints.City.label}" id="c1" styleClass="#{ColorSwitchBean.styleClass}">
  <af:outputText value="#{row.City}" id="ot2" /> Timo

Similar Messages

  • How to change the background color of a single row

    Hi OTN,
    I am using JDeveloper 11.1.1.2 with ADF faces in view layer.My issue is How to change the background color of a single row in af:table ?.

    How to highlight ADF table row based on column value?
    Found by searching

  • I just want to know that how to change the font color, font size, and forgr

    i just want to know that how to change the font color, font size, and forground color in JTextPane for the Selected text. i try diffrerent menthod like setFont and setColor, these methods change the fonts of the whole textpane. so please reply me as soon as possible, and thanks in advance.
    Moazzam

    Sell the Old one... Buy a New one...

  • Change the font color of a text field in a table by key-combination

    I want to change the font color of a text field in a table (single cell only) on pressing a key combination. Does anybody know how to do this.
    I have a lot of data in a table. During an evaluation of the data in a meeting I want to change the color of the text depending on the result of the meeting. (for example: High risk = CTRL+R makes the text red).
    I know how to change the color using a button, but I do not want to add a button after each cell. For this reason I would like to do it on a key combination that alway refers to the active cell.
    Many thanks for your help in advance.
    Marcel

    Hi,
    I don't think you can use the ctrl key like that as those shortcuts will be intercepted by Reader (ctrl-R toggles the ruler display on / off).  You also might have trouble updating the color while you still have focus on it.  You can use the shift key in a similar way, so if you only have lower case characters in the text fields then you can do something like;
    if (xfa.event.shift)
        switch (xfa.event.change)
            case "R":
                this.fontColor = "255,0,0";
                break;
            case "O":
                this.fontColor = "255,102,0";
                break;
            case "G":
                this.fontColor = "0,255,0";
                break;
        xfa.event.change = ""; // ignore character
    If you need uppercase characters maybe you can have one button to set "review mode" and test that on the if (xfa.event.shift) line.  But again it wont take effect until you have tabbed out of the field.
    Regards
    Bruce

  • How to change the font color in a strict type def programatically

    Could someone suggest a way to change the font color of a string indicator in a strict type def cluster programmatically? The cluster contains a label that is color-coded to match the function of the data channel represented by that cluster.  The function of each channel is not predetermined, so the font color needs to be changed programmatically.  To represent all channels, I have arranged a large cluster that contains 100 instances of the control.  This makes it essential that the control be strictly type defined in order to change the layout of the clusters uniformly.
    Can anyone suggest either a method by which I can let the control remain a strict type def and change the font color, or a method by which I can programmatically change the control from a strict type def to a type def?  Currently, I am saving the control as a strict type def every time I make a change and then saving it again as a type def when I am ready to run the program.  This works fine, but just seems inelegant.  This color-coding is used throughout the program in various indicators, so a neat solution would be greatly appreciated.

    As mentioned in my Nugget on Type definitions you can create strict type-defs that contain type-defs.
    If you make your data definition a type and put that definition in a strict type-def (one of each flavor) you can use the appropraite strict type where each is required.
    Yes the data structure will have another level of nesting so if you are "too far gone" you may not like this idea.
    Otherwise you can write a VI that opens the typed-def and do a "save as..." and use it everytime you edit the type-def.
    I hope something helps!
    Ben
    Message Edited by Ben on 10-06-2008 10:26 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Strict_of_Typedefs.PNG ‏30 KB

  • How to Change the Font Color in the Podcast Archive Subheadings

    If you go to pages.sparcc.org/The _Sanctuary, you will notice that the font colors in the subheadings are red. I was able to change them to the green everyone wanted except for the red "Archives". How can I change them?

    Unfortunately, the text stylings for both the main blog index page as well as the archive page are controlled by the template. If you want, you can edit the xml template files buried in the iWeb application itself, but there is no way to do this from within iWeb directly.

  • How to change the font color of a disabled item

    Can I change the default color of a disabled item from gray to something else? I've tried to put style="color:darkblue" in the HTML form element attributes but it didn't worked.

    Hi,
    Code probably run, but IE do not just understand CSS what code set ?
    I did find something related
    http://www.askthecssguy.com/2007/05/shawn_asks_the_css_guy_about_s_1.html
    Regards,
    Jari
    Edited by: jarola on Oct 27, 2010 11:24 PM
    And this
    http://stackoverflow.com/questions/602070/changing-font-colour-in-textboxes-in-ie-which-are-disabled

  • Change the background color of a particular word without changing the background color of the rest of the text in a textbox

    Hello,
    I'm designing my own website and want to know how to change the background color of a particular word without changing the background color of the rest of the text in a textbox. If i can't do this, how can I create a Table, similar to Excel with iWeb?
    Thank you very much!
    Roger.

    If i can't do this, how can I create a Table, similar to Excel with iWeb?
    Read this :
         Create and add a TABLE in iWeb »
         More about a TABLE in iWeb »
         Sample 1
         Sample 2

  • How do I change the font color for numbering in a matching question slide?

    I have a grey image on a question slide, but the numbering for the answers in a matching question is defaulting to grey so learners can't see to match up.  How can I change the font color of these choices?  Thanks.

    You probably edited the master slide without changing the theme colors? Check the Object Style for Answers in the Object Style Manager. The numbering takes the same color as the answer text.
    All depends on the Theme colors palette that you are using. Normally Question answers use the darkest tint of the fourth color. I started blogging about color management, but description of the use of Theme colors will be published later.
    Colorful 2015 with Adobe Captivate - Captivate blog

  • How do I change the font color in Live Type?

    How can I change the font color in Live Type?

    By trial and error, I also learned that the slide icon just to the right of the color box must be moved to the right in order for the new color to be visible. Of course, the amount to which the slide is moved determines the intensity of and color. Thanks for putting me on the right track (no pun intended).

  • How do you change the font color in CALL-OUT text boxes in PRO XI?

    How do you change the font color in CALL-OUT text boxes in PRO XI?

    It's not so simple to find it if you don't know what you're looking for... But it can be found via View - Show/Hide - Toolbar Items - Properties Bar.

  • When composing an email, how do I highlight a word in yellow (NOT change the font color, just highlight)?

    On Windows when composing an email,  I would often highlight a word or sentence in yellow. I don't seem to have this option on my Mac Book Air toolbar as I did when I had on my laptop. How can I add this feature to my toolbar? I don't want to change the font color, just want to highlight a word within the email.
    Thank you,

    Browder-41 wrote:
    How to I copy a Word document into an email without losing the design and colors in the document.  When I copy and paste I only get the typed words.  No design or color.
    You may or may not be able to do this based on which e-mail client or webmail platform you're using.  In your email options, you'll want to have the option to paste it as rich-text or HTML.  If you only have the option for plain text then you're out of luck.

  • How to change the font, the font size, and color text

    How to change the font, the font size, and the color for a selected text in C++.
    David

    Look at the documentation in the SDK about how to build a plugin and then the PDEdit APIs available to them.

  • How to change the background and font color of a particular row in table

    Hi,
       i need to change the background and font color of a particular row. I am using textview as table columns. I tried to do it using semanticColor property of textview  but the font color get changed for the whole column. But i want to change the color of a particular row only.
       If anybody knows please help me(give an example if possible).
           Thanks and regards.
            Pankaj Kumar.

    Hi Pankaj,
    In your data source context node (context node which is bound to dataSource property of Table UI elemennt) do following:
    If data source node is model node: create a value node under data source node, cardinality 1..1, selection 1..1, singleton false. In this new node add value attribute and set property readOnly=true, calculated=true, property com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor .
    If datasource node is value add value attribute and set property readOnly=true, calculated=true, property com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor.
    In calculated getter method put your color calculation depending on conditions, like:
    return <condition>
      ? WDTextViewSemanticColor.CRITICAL
      : WDTextViewSemanticColor.STANDARD;
    Bind new created attribute with property semanticColor of textview.
    Best regards, Maksim Rashchynski.

  • How can i change the font color in TextArea ?

    I want to change the font color in text area or text field
    i'm not using swing (i'm using only AWT)
    so don't show me solutions in swing because it won't help me.
    is it possible anyway?
    thanx

    Hi,
    Have you tried the following ?
    yourTextArea.setBackground(yourColor);with yourColor being a Color object.
    BadLands

Maybe you are looking for

  • New to Java and I guess a scope question.

    Hello and thank you for taking the time to read this. I am not a real programmer, everything I have ever done was a total hack, or written without a full understanding of how I was doing it. One thing about Java is that you might have like 20 classes

  • WHAT IS USE OF CHANGE DOCUMENT FIELD?

    HI experts, go like this,   mara->matnr->dataelement of matnr->further charecteristics ->change document in this if we select change document field what will be occured , if we deselect   thatfield what will be the changes and where will be reflected

  • File picking and placing in same dir App server of SAP XI using NFS.

    Hi All, As I am new to XI, I am using XI 3.0, My scenario is  File ->XI-> File. This is just a pass through data that is no IR objects. I need to pick the file from App server(AL11) of R/3 sys , we have a dir as "/sai/output" so in order to pick file

  • Starting jar-files in Windows XP

    I've installed the latest JDK a while ago and everything went smooth until I installed a program to open zip-files (Filzip). After installing this it claimed responsibility for jar-files too, associating the .jar with it. Now all .jar files are of th

  • Internal Mic in MacBook Pro 9,2 (mid-2012)

    I'm trying to get my internal mic to work after my recent install on a MacBook Pro 9,2 (mid-2012), but without much success.  I've installed alsa, alsa-utils, alsa-plugins, etc., and audio output works fine, but the internal microphone still doesn't