|| | |||Browse by category|
How to hide and show the label of
You can achieve this in two ways:
- Through API:
- By default,
IlvGeneralLink's label is represented by an IlvZoomableLabel at the first slot of the decoration list. You can remove or add the label decoration to hide or show the label.
- Alternatively, you can hide the label by using the fully transparent color at the label graphic object. Something like the following:
IlvGeneralLink linkGraphic = ...;
IlvGraphic label = linkGraphic.getDecorations(0);
boolean isVisible = label.isVisible();
// make label invisible
// make label visible
linkGraphic.reDraw(); // important to force a refraw here
- By default,
- Through CSS:
You need to subclass the IlvGeneralLink and store the label internally. In your subclass, you need to provide a getter and setter for labelVisible property. When this property is set to true in the CSS file, you can set the label value to the parent class in order to add the label as a decoration.
Then in the CSS file, you can configure the label and its visibility like the following:
class : "MyGeneralLink";
// replace labelValue with the appropriate model attribute name
label : "@labelValue" ;
// this is new property available in the MyGeneralLink class
labelVisible : "true";
This will enable you to toggle the label's visibility via CSS while maintains the label value at the graphic level.
Attached is the sample that demonstrates both approaches.