Add single word attribute to the output of a component - attributes

I'd like to output as a single word attribute in html. The source is an AEM dialog that's structured as a radio group.
<items jcr:primaryType="nt:unstructured">
<colorpref jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/radiogroup"
fieldLabel="Choose Color Pref"
name="./scheme" vertical="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<primary jcr:primaryType="nt:unstructured"
text="Primary"
value="primary"/>
<secondary jcr:primaryType="nt:unstructured"
text="Secondary"
value="secondary"/>
<parentcolor jcr:primaryType="nt:unstructured"
text="Use Parent Color"
value="useparentcolor"/>
</items>
</colorpref>
</items>
And then from the dialog output the value of the selected value as a single word
<element selectedoption ...
instead of
<element selectedoption='true' ...
The code I'm using to write the attribute is
"${button.scheme # context='html'}"
but that isn't creating any text. I've replaced the html in context phrase with attribute and text but neither of those work.
I'm using javascript to build the model that's referenced by button in the code.
So how do I output a single word attribute from the dialog in AEM?

The solution is to use the data-sly-attribute.
data-sly-attribute.danger="${ insert test here }"
which will output just the single word danger in the element.

Related

WP All Import creates duplicate product attributes

I'm using WP All Import to import new products from an XML, or update them. The import works perfect, but I noticed that some attributes are double. They have been created again, after first import.
Maybe for new items. I checked XML file and it is normal.
I want to import toners and I'm using an attribute for color (Χρώμα in greek) and now i have 2 different attributes named Χρώμα with the same colors. Looking for CYAN color, I found 5 products in the first attribute and 11 products in the second one.
Any idea what I'm doing wrong?
Here is the xml from one product:
<product>
<id>1077</id>
<sku>TON-CLP320BK</sku>
<name>
Συμβατό Toner TON-CLP320BK για Samsung, CLT-K4072S, Black, 1.5K
</name>
<barcode>5202705407213</barcode>
<manufacturer>PREMIUM</manufacturer>
<descr>
<p>Συμβατό Toner TON-CLP320BK για Samsung, CLT-K4072S, Black, 1.5K</p><p></p><p>Συμβατά μοντέλα : </p><p>CLP325<br/>CLP320<br/>CLP320N<br/>CLP325W<br/>CLX3185FN<br/>CLX3185FN<br/>CLX318<br/>CLX318FN<br/>CLX3185FW<br/>CLX3185W</p>
</descr>
<availability>1</availability>
<dim1>40.0</dim1>
<dim2>9.5</dim2>
<dim3>18.5</dim3>
<weight>0.791</weight>
<tax>0.000</tax>
<stock_indicator>20</stock_indicator>
<minimum_quantity_to_order>1</minimum_quantity_to_order>
<RRP>15.00</RRP>
<url>
https://www.data-media.gr/product_det.asp?catid=263&subid=329&prid=1077
</url>
<thumb>
https://www.data-media.gr/photos/TON-CLP320BK.jpg
</thumb>
<image>
https://www.data-media.gr/photos/max/TON-CLP320BK.jpg
</image>
<volume>7030.000</volume>
<courier_weight>1.786</courier_weight>
<in_offer>0</in_offer>
<guarantee>12 μήνες</guarantee>
<group>
<id>4</id>
<name>Εκτυπωτές & Toner-Ink</name>
<category>
<id>263</id>
<name>Toner - Ribbon Μελάνια</name>
<subcategory>
<id>329</id>
<name>Toner</name>
</subcategory>
</category>
</group>
<filters>
<filter>
<name_id>9</name_id>
<name>Για Brand</name>
<value_id>8</value_id>
<value>SAMSUNG</value>
</filter>
<filter></filter>
<filter></filter>
<filter></filter>
</filters>
<price>10.16</price>
<price_without_offer>10.16</price_without_offer>
<retail_percent>20</retail_percent>
<retail_price>15.12</retail_price>
<vat>24</vat>
<pp>0</pp>
</product>

How can I resize table column width while designing Maximo anywhere app

I have tried using usefieldsizegroup="false" and then setting width and size values , however the column width are not getting adjusted.
I think that flag tells maximo to not use the default field sizes based on field types (text box, table column, text editor, etc...). At least that's how I took their documentation:
http://www-01.ibm.com/support/docview.wss?uid=swg21388710
I was able to resize table column fields in Maximo (didn't try Anywhere-Maximo) by using a 'width' flag in the XML like so:
<tablecol dataattribute="CHANGEDATE" id="11111111111" label="Change Date" width="120"/>
You can edit the layout which is associated with the listItemTemplate element of your list. For example we want to change the width of the text field on position item3:
<listItemTemplate id="xxxxx" layout="WorkListItem">
<listtext layoutInsertAt="item3"
In this example You can find this layout template at /apps//artifact/layouts/templates/small/WorkListItem.xml
When you open this file you will see the definition of your list layout. Search the "item3" place in the layout. By editing the colspan attribute you can manipulate tablecol width:
<?xml version="1.0" encoding="UTF-8"?>
<layout id="WorkListItem" width="100">
<row id="row_0">
<column colspan="10" columnid="item3" id="item3_column"/>
<column colspan="2" columnid="button1" halign="right" id="button1_column" rowspan="3"/>
</row>
<row id="row_1">
<column colspan="8" columnid="item1" id="item1_column"/>
<column colspan="2" columnid="item2" id="item2_column"/>
</row>
<row id="row_2">
<column colspan="5" columnid="item4" id="item4_column"/>
<column colspan="5" columnid="item5" id="item5_column"/>
</row>
</layout>

How to get the attribute value of an xml code using linq

<Shape ID="1" NameU="Start/End" Name="Start/End" Type="Shape" Master="2">
....</Shape>
<Shape ID="2" NameU="Start/End" Name="Start/End" Type="Shape" Master="5">
....</Shape>
I have to return the Master value for every ID value.
How can i achieve it by using LINQ to XMl.
You didn't really present how your XML document looks like, so I assumed it's as follow:
<Shapes>
<Shape ID="1" NameU="Start/End" Name="Start/End" Type="Shape" Master="2">
</Shape>
<Shape ID="2" NameU="Start/End" Name="Start/End" Type="Shape" Master="5">
</Shape>
</Shapes>
You can simply get Master attribute value for all different ID like that:
var xDoc = XDocument.Load("Input.xml");
var masters = xDoc.Root
.Elements("Shape")
.ToDictionary(
x => (int)x.Attribute("ID"),
x => (int)x.Attribute("Master")
);
masters will be Dictionary<int, int> where key is your ID and value is corresponding Master attribute value.

JavaFX & FXML: how do I set the default selected item in a ChoiceBox in FXML?

I have the following FXML:
<ChoiceBox>
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="2 minutes" />
<String fx:value="5 minutes" />
<String fx:value="15 minutes" />
</FXCollections>
</items>
</ChoiceBox>
But in the GUI it just shows a ChoiceBox with a default of nothing. I would like the first element in the list to be the default, and for a choice of "null" or nothing to be prohibited.
How do I accomplish this?
I added the value attribute to the ChoiceBox tag, and that worked.
<ChoiceBox value="2 minutes">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="2 minutes" />
<String fx:value="5 minutes" />
<String fx:value="15 minutes" />
</FXCollections>
</items>
</ChoiceBox>
First, you should import your needed value model, like Crowell answer, you should import like this in your fxml header:
<?import javafx.collections.*?>
Second, if you want's import your own model, import it first and then like this:
<?import com.zzg.mybatis.generator.model.*?>
....
<ChoiceBox layoutX="24.0" layoutY="14.0" prefWidth="150.0">
<items>
<FXCollections fx:factory="observableArrayList">
<DatabaseDTO name="MySQL" value="1"></DatabaseDTO>
<DatabaseDTO name="Oracle" value="2"></DatabaseDTO>
</FXCollections>
</items>
</ChoiceBox>
#Groostav: In case we programmatically "know" the value that should appear as selected (for example, we landed in an edit form), we can do the following:
1) Add a new item with index 0 (that is, the element we need to show as selected):
myChoiceBox.getItems().add(0, ItemObtainedProgrammatically);
2) Show the item as selected (since we already know it's at position 0):
myChoiceBox.getSelectionModel().select(0);
Probably this qualifies as a dirty hack, but it works. The con: You have the same item twice in your choicebox

Displaying string text in flex

relatively new to flex. I am trying to display text from a string on a view. I would like if it wasn't in a list/button/text area but just text. I know how to display text but I'm not sure how you would take text from a string and put it to text on the screen. Thanks for the help!
Flex MXML has Label which would adhere to lifecycle and visual element display list.
Marking the string with the Bindable metadata tag will automatically update the rendered label when the value of the string changes.
<?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">
<fx:Script>
<![CDATA[
[Bindable]
protected var text:String = "Hello, World!";
]]>
</fx:Script>
<s:Label text="{text}" />
</s:Application>
Otherwise, you can still use standard TextField or even TLFTextField controls.

Resources