XPage : Add a styleClass to a given styleSheet of a XPage - css

How do I add a styleClass to a given XPage styleSheet ?
.required {
background: red;
}
I want to do the same as Knut Herrmann answered here but unfortunately it is not shown how to add that class to the XPage styleSheet (resp. edit that styleSheet). So how to achieve that ?

Create a css file in database's Resources / Style Sheets
and add this css file as resource to your XPage in XPage's property "Resources".

1) Create your own stylesheet file in your database (e.g. custom.css under resources/stylesheets)
2) Now you can add a new styleclass to your stylesheet file or you can overwrite an existing styleclass
Overwrite example:
XPage:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="/custom.css"></xp:styleSheet>
</xp:this.resources>
<xp:text escape="true" id="computedField1" value="Hello"></xp:text>
</xp:view>
custom.css:
.xspTextComputedField {
font-weight: bold;
}
"New" example:
XPage:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="/custom.css"></xp:styleSheet>
</xp:this.resources>
<xp:text escape="true" id="computedField1" value="Hello" styleClass="customXspTextComputedField"></xp:text>
</xp:view>
custom.css:
.customXspTextComputedField {
font-weight: bold;
font-size: 20pt;
}

Related

adding css to gtk4 application

I have a ui definition file as follows:
<object class="GtkLabel" id="view_header">
...
</object>
and css as follows:
#view_header { font: 1.2em bold }
Since the class attribute is already used to define the ObjectClass, how do I define a "css class" that I can use to select multiple view headers?
You should use the css-classes property of your object to set the classes that are applied to it. For example, changing your object to use a custom some-class:
<object class="GtkLabel" id="view_header">
<property name="css-classes">some-class</property>
</object>
Then, on your .css file, you just define your styles as usual.
#view_header { font: 1.2em bold }
.some-class {
// whatever you want...
}
#view_header.some-class {
// whatever you want...
}
...

Is there a way to reference a class in an xml sheet using css?

Here is the Xml, I was wondering how you would reference the class "down" using css so I can style all similar code sections the same? This is just a clip I have the css correctly referenced at the start of my xml file
<stock class="down">
<symbol>AAPL</symbol>
<company>Apple Computer, Inc.</company>
<lastSale>$15.26</lastSale>
<netChange>-0.17</netChange>
<pChange>-1.10%</pChange>
<volume>5.548</volume>
</stock>
Your XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="styles.css"?>
<stock class="down">
<symbol>AAPL</symbol>
<company>Apple Computer, Inc.</company>
<lastSale>$15.26</lastSale>
<netChange>-0.17</netChange>
<pChange>-1.10%</pChange>
<volume>5.548</volume>
</stock>
Your styles.css CSS:
.down {
//Your styles here
}
Or:
stock.down {
//Your styles here
}
Or:
[class~=down] {
//Your styles here
}
Or:
stock[class~=down] {
//Your styles here
}

Small text in spark label looks bloor

I spent a few days to find solution to solve this problem. Before using spark label, im use mx label, and text with small size (textSize:11) looks clear. After change component on spark label, text looks blurry, not soo clear. Im embed font from my system. Font name is Tahoma. Changing values like cffHinting dont give me any result. I'm use flashDevelop, but same result in IDEA and FlashBuilder. I cant post screenShot bicouse of my small reputation level. Help me please find right solution.
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
#font-face{
src:url("Tahoma.ttf");
font-family:TahomaS;
embedAsCFF: true;
}
#font-face{
src:url("Tahoma.ttf");
font-family:TahomaMX;
embedAsCFF: false;
}
s|Label
{
font-family:TahomaS;
font-size:11;
color: #5c5c5c;
}
mx|Label
{
font-family:TahomaMX;
font-size:11;
color: #5c5c5c;
}
And code from Main.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Style source="Fonts.css"/>
<s:Label x="50" y="50" text="XYZ Corporation Directory" cffHinting="none" />
<mx:Label x="50" y="65" text="XYZ Corporation Directory" />
</s:Application>
I think that blurry effect and size label text change is because that your flex compiler can't locate the specified font, so it use the default font.
1 - use local() to locate local font like this :
#font-face {
src: local("Tahoma");
fontFamily: "TahomaS";
embedAsCFF: true;
}
s|Label {
fontFamily: "TahomaS";
fontSize: 44;
}
2 - create a flex config file local-font-config.xml in your src/ folder and specify your font path :
<?xml version="1.0" encoding="utf-8"?>
<flex-config>
<compiler>
<fonts>
<local-font-paths>
<path-element>/System/Library/Fonts/</path-element>
</local-font-paths>
</fonts>
</compiler>
</flex-config>
3- give to your flex compiler the location of your config file :
-load-config+=local-font-config.xml
... i think that the best way to use fonts is to use it as a project resources, so you avoid additional configurations
Just create an src/assets/fonts folder in your project and put in your fonts
and in your css file just do this :
#font-face {
src:url("assets/fonts/Tahoma.ttf");
fontFamily: "TahomaS";
embedAsCFF: true;
}
s|Label {
fontFamily: "TahomaS";
fontSize: 44;
}

How to give background color for input textBbox in ADF Mobile?

I am trying to give background color for Input TextBox. If I used inline Style it will giving color to field. Now how can I change my background color.
Below is my code:
<?xml version="1.0" encoding="UTF-8" ?>
<amx:view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amx="http://xmlns.oracle.com/adf/mf/amx"
xmlns:dvtm="http://xmlns.oracle.com/adf/mf/amx/dvt">
<amx:panelPage id="pp1">
<amx:facet name="header">
<amx:outputText value="Header" id="ot1"/>
</amx:facet>
<amx:inputText label="Name" id="it1" inlineStyle="background-color:blue;"
value="#{preferenceScope.feature.feature1.security.username}"/>
<amx:inputText label="Password" id="it2"
value="#{preferenceScope.feature.feature1.security.password}"/>
<amx:inputText label="URL" id="it3" value="#{preferenceScope.feature.feature1.security.url}"/>
</amx:panelPage>
</amx:view>
Below is Out Put:
Create CSS file (new => html => css file) and add below code
.textcolor input{
background-color:Blue !important;
}
in input text Style Class property write textcolor (the class you just added to the css file).
then open adfmf-feature.xml select your feature under content tab include the css file you created.
That's it.

How to remove autospace between elements in xml?

There's an xml document like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml-stylesheet href="#style" type="text/css"?>
<root>
<style>
style {display: none}
entry {display: block}
english {font-weight: bold}
spanish {font-style: italic}
</style>
<entry>
<sense_unit>
<english>abandon</english>
<spanish>abandonar</spanish>
</sense_unit>,
<sense_unit>
<english>friend</english>
<spanish>amigo</spanish>
</sense_unit>
</entry>
</root>
Web browser renders this:
style {display: none} entry {display: block} english {font-size: 10pt; font-family: "Times New Roman"} spanish {font-size: 9pt; font-family: "Arial"}
abandon abandonar , friend amigo
I'd like to hide the contents of style element, but it still appears.
I don't want the space between abandonar and the following comma. (But I don't want to insert the comma inside the sense_unit) How can I do that? (That is, ... abandonar , friend ... -> ... abandonar, friend ...)
This has nothing to do with css, and everything to do with well-formed XML. All linebreaks in XML are considered an element and therefore will create those spaces. Remove all your line-breaks and those spaces will disappear.
Update jsFiddle example where I've removed all your line breaks and spaces just within the <entry>

Resources