-
Notifications
You must be signed in to change notification settings - Fork 3
2. How to create CssFile for dynamic css
Web Firm Framework edited this page Nov 17, 2015
·
1 revision
A css file can be created by extending CssFile class, please check the below sample
import java.util.Set;
import com.webfirmframework.wffweb.css.BackgroundRepeat;
import com.webfirmframework.wffweb.css.ListStylePosition;
import com.webfirmframework.wffweb.css.core.CssProperty;
@SuppressWarnings("serial")
public class CssFileSample1 extends CssFile {
public CssFileSample1() {
}
// to exclude this block of styles
@ExcludeCssBlock
private final CssBlock cssBlock5 = new CssBlock(".test5-class") {
@Override
protected void load(final Set<CssProperty> cssProperties) {
cssProperties.add(ListStylePosition.INSIDE);
}
};
private final CssBlock cssBlock6 = new CssBlock(".test4-class") {
@Override
protected void load(final Set<CssProperty> cssProperties) {
cssProperties.add(BackgroundRepeat.NO_REPEAT);
cssProperties.add(ListStylePosition.OUTSIDE);
}
};
@Override
public String toString() {
return "CssFileSample1";
}
}
the following code
public static void main(String[] args) {
final CssFileSample1 cssFileSample1 = new CssFileSample1();
final String cssString = cssFileSample1.toCssString();
System.out.println(cssString);
}
will print
.test4-class {
background-repeat: no-repeat;
list-style-position: outside;
}
Refer wffweb-javadoc, Watch technical videos
Feel free to write us @ [email protected] for any assistance
or
[email protected] for any technical support.
webfirmframework.com since 2014