Topic
  • 3 replies
  • Latest Post - ‏2013-12-16T15:25:52Z by mburati
pdesandi
pdesandi
2 Posts

Pinned topic How to change color attributes of cells within a table

‏2013-12-13T14:02:34Z |

What's the recommended way to change the cell background color for particular cells within at table, based on a value returned from a database value?  For example, suppose there's a page table that has 3 rows and 3 columns.  Each cell within the table can have a variable background color that would be determined from a value returned from a database table.  For simplicity, let's assume that all the cell's background colors would be the default of white.  A query then returns a row of values from a database look-up via a service provider.  The returned values form the table row are either  '1s' or '0s'.  If the value is '1', we would simply want to change the cell background of a particular cell to blue.  This sounds simple enough to do (possibly via the Attribute Builder), but still need some advice on how best to accomplish this.

  • mburati
    mburati
    2579 Posts

    Re: How to change color attributes of cells within a table

    ‏2013-12-13T14:32:07Z  

    For a traditional WEF server-side app (eg, not 8.0 optional client-side app where the UI is managed via JS in the browser),  the way I've seen this done is typically via an Attribute Setter with the value coming from the result of a method call where the method looks at the data value and returns the appropriate style value based on that value.

     

    I hope that info helps,
    ..Mike Burati 
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • pdesandi
    pdesandi
    2 Posts

    Re: How to change color attributes of cells within a table

    ‏2013-12-16T13:52:28Z  
    • mburati
    • ‏2013-12-13T14:32:07Z

    For a traditional WEF server-side app (eg, not 8.0 optional client-side app where the UI is managed via JS in the browser),  the way I've seen this done is typically via an Attribute Setter with the value coming from the result of a method call where the method looks at the data value and returns the appropriate style value based on that value.

     

    I hope that info helps,
    ..Mike Burati 
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

    I was successful in changing individual cell colors.  I created an Action List which which contained IF, THEN boolean logic.  It simply looked at the returned table row value and assigned a color to a variable that was then returned to the MethodCall from the Attribute Setter Builder.  For example, in the Attribute Setter Builder Value field I called an Actionlist method.   The Value field is: ${MethodCall/SetCellColor}.  The SetCellColor Action List assigns a color to a variable and then returns it.  I may not be familiar enough with the syntax of what the Value field can contain in the Attribute Setter Builder.  Is it possible to have all the commands in the Value field so I wouldn't have to call the Action List?  If so, can you provide an example?

  • mburati
    mburati
    2579 Posts

    Re: How to change color attributes of cells within a table

    ‏2013-12-16T15:25:52Z  
    • pdesandi
    • ‏2013-12-16T13:52:28Z

    I was successful in changing individual cell colors.  I created an Action List which which contained IF, THEN boolean logic.  It simply looked at the returned table row value and assigned a color to a variable that was then returned to the MethodCall from the Attribute Setter Builder.  For example, in the Attribute Setter Builder Value field I called an Actionlist method.   The Value field is: ${MethodCall/SetCellColor}.  The SetCellColor Action List assigns a color to a variable and then returns it.  I may not be familiar enough with the syntax of what the Value field can contain in the Attribute Setter Builder.  Is it possible to have all the commands in the Value field so I wouldn't have to call the Action List?  If so, can you provide an example?

    It sounds like the way you solved it is reasonable and similar to what I was suggesting (I would've used a Java method/ljo method rather than an action list as I personally like to keep conditional logic and more complex logic out of action lists, but what you did seems ok).    While you can use a ${Java/insert-some-java-expression-here}  with an inline java expression (must result in a String)  I wouldn't personally recommend it as it can start to make your builder calls and models harder to read/understand and thus harder to maintain over time if you start hiding conditional logic in builder inputs rather than in Action Lists and LJO methods.

     

    I hope that info helps,
    ..Mike Burati 
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.