0

I have data grid and table.In data grid ,I have command buttons for every location. In(mysql) table I have id,date,location attributes. The button should get coloured based on the id present in the table. how can I get this? please do some favour..Thanks in advance..

This is my command Button ..

<h:commandButton  id="login" value="Reason"     
         style="#{home.rest()},height: 20px;left: 200px;font-size: 50%;bottom: 1px;font-family: bold;position: relative" />

I have used Java method..here it is...

 public String rest(){
 String a;
 String table_id;     
 List user=new ArrayList();
 DBQuery db=new DBQuery();
 user=db.table(getDate());
 String id="";
 List off=new ArrayList();
 off = db.entire_location(toDate(),getDate());
    for(int j=0;j<user.size();j++){
      for(int i=0;i<off.size();i++){ 
 home_bean hello = (home_bean)user.get(j);
    table_id=hello.getable_id();
            home_bean hi = (home_bean)off.get(i);
  id= hi.getentire_id();
     if(id.equals(table_id)){
       System.out.println("True");
   a="red";
//           return "background-color: red;width:100%";
       } else
     a="";
 System.out.println("Fallse");
           }}return "a";
 }
Rangith
  • 39
  • 2
  • 9

2 Answers2

0

I think what you should do is the following :

1- create a variable in your bean :

 private String style;

    public void setStyle(String style) {
        this.style = style;
    }

    public String getStyle() {
        return style;
    }

2- in your JSF tag do like the following :

<h:commandButton  id="login" value="Reason"     
         style="#{bean.style}" />

and try to put your java code in the setStyle method

Hope That Helps.

-1

dude Is this correct way to put in the style attribute..

style="#{home.rest()},height: 20px;left: 200px;font-size: 50%;bottom: 1px;font-family: bold;position: relative" />
Rangith
  • 39
  • 2
  • 9