Skip to content

Instantly share code, notes, and snippets.

@edubriguenti
Created September 30, 2014 19:21
Show Gist options
  • Save edubriguenti/27bdec23ccc7948d9761 to your computer and use it in GitHub Desktop.
Save edubriguenti/27bdec23ccc7948d9761 to your computer and use it in GitHub Desktop.
Adicionar CSS em comopoenent no managedBean
private static void adicionarCss(final String id, final String css) {
final UIComponent component = getComponenteById(id);
if(component!=null){
if(component instanceof HtmlInputText){
final HtmlInputText input = ((HtmlInputText)component);
if(input.getStyleClass()==null){
input.setStyleClass(css);
}else{
input.setStyleClass(input.getStyleClass()+" "+css);
}
}else if(component instanceof HtmlSelectOneMenu){
final HtmlSelectOneMenu select = ((HtmlSelectOneMenu)component);
if(select.getStyleClass()==null){
select.setStyleClass(css);
}else{
select.setStyleClass(select.getStyleClass()+" "+css);
}
}else if(component instanceof HtmlOutputText){
final HtmlOutputText outputText = ((HtmlOutputText)component);
if(outputText.getStyleClass()==null){
outputText.setStyleClass(css);
}else{
outputText.setStyleClass(outputText.getStyleClass()+" "+css);
}
}else if(component instanceof HtmlPanelGroup){
final HtmlPanelGroup panelGroup = ((HtmlPanelGroup)component);
if(panelGroup.getStyleClass()==null){
panelGroup.setStyleClass(css);
}else{
panelGroup.setStyleClass(panelGroup.getStyleClass()+" "+css);
}
}else if(component instanceof HtmlOutputLabel){
final HtmlOutputLabel outputLabel = ((HtmlOutputLabel)component);
if(outputLabel.getStyleClass()==null){
outputLabel.setStyleClass(css);
}else{
outputLabel.setStyleClass(outputLabel.getStyleClass()+" "+css);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment