Displaying string text in flex - string

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.

Related

Add single word attribute to the output of a component

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.

ODOO 11 report, object has no attribute 'report_action'

Good day to all.
Trying to make custom ODOO 11 report to save it to pdf.
Report template(w/out any values, just for test purposes)
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="contract_template">
<t t-call="web.html_container">
<div class="article">
<h2>Report title</h2>
<p>Report 01</p>
</div>
</t>
</template>
</data>
</odoo>
If I call this template from XML like this:
<report
id="custom_template_1"
model="res.partner.contract.wizard"
string="Contract"
report_type="qweb-pdf"
name="client_contracts.contract_template"
file="client_contracts.contract_template"
menu="False"
/>
And add button to view it works fine - it generate report.
But when I'm trying to generate this report with python code:
def get_pdf_contract(self):
context = self._generate_context()
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
And add button to view:
<button string="Test pdf x" type="object" name="get_pdf_contract" />
When I press this button there is an error:
AttributeError: 'ir.ui.view' object has no attribute 'report_action'
Anyone can give me helping hand with that? Thanx for any help.
Found solution.
For anyone, who get same error/trouble - solution.
Just skip the
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
part, and replace it with
return {'type': 'ir.actions.report','report_name': 'client_contracts.contract_template','report_type':"qweb-pdf",'data': context,}
where context - previously generated dict of values, that need to be passed to template.
client_contract - name of module, conrtact_template - name of template
replace
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
with
return self.env.ref('client_contracts.custom_template_1').report_action(self, data=context)
means
return self.env.ref('module.report id').report_action(self,data=context)
The solution to this stack overflow question link, works fine.
To note: the report_id referenced below should refer to the report where you have declared name of report and type and file ... and not the template_id.
return self.env.ref('module_name.report_id').report_action(self, data=context)

Converting XML to string and back to XML retaining the comments and order of the tags as it is

I have an XML and it contains a tag which has a value I want to replace in nodeJS.
The XML contains comments and attributes to the tags.
Most parsers convert the XML to JSON and do the replace in the process of which, the comments get lost in the final file.
So I thought of doing a XML to string conversion and replace and then back to XML.
I am unable to convert the string back to XML as many existing libraries in node either are converting to JSON, are unable to to parse attributes with ':' in it.
So any Solution for the same is appreciated.
N.B - the XML needs to be exactly the same as earlier in exception to only the one tag value I replace.
The order of the tags and the comments are important as there is a checksum calculation involved.
Sample Input :
<?xml version="1.0" encoding="UTF-8"?>
<session abc:def ="dines/dwivedi.../nodeJS/developer" name="Dinesh_Dwivedi"
samp1:display="sample/text1"
samp2:display="sample/text2"
samp3:display="sample/text3">
<view name="viewer/name1" type="good.sample.data1">
<feature ="text1" value="1:1"/>
<!--This is a sample comment-->
</view>
<view name="viewer/name2" type="good.sample.data2">
<feature ="text2" value="1:2"/>
<!--This is a sample comment too-->
</view>
<!--again another Sample comment-->
</session>
Text to change - Dinesh_Dwivedi
Replace Text - Dines_Dwivedi
Final Output -
<?xml version="1.0" encoding="UTF-8"?>
<session abc:def ="dines/dwivedi.../nodeJS/developer" name="Dines_Dwivedi"
samp1:display="sample/text1"
samp2:display="sample/text2"
samp3:display="sample/text3">
<view name="viewer/name1" type="good.sample.data1">
<feature ="text1" value="1:1"/>
<!--This is a sample comment-->
</view>
<view name="viewer/name2" type="good.sample.data2">
<feature ="text2" value="1:2"/>
<!--This is a sample comment too-->
</view>
<!--again another Sample comment-->
</session>

Xpages Extlib dataView control sets "display:none;" style when column has empty value

I have a xpage with Extension Library DataView control. I have defined several extra columns there.
<xe:dataView id="dataView1"
<xe:this.data>
<xp:dominoView var="vMyView" />
</xe:this.data>
<xe:this.summaryColumn>
<xe:viewSummaryColumn columnName="$DateFrom"
columnTitle="Date From">
</xe:viewSummaryColumn>
</xe:this.summaryColumn>
<xe:this.extraColumns>
<xe:viewExtraColumn columnName="$DateTo"
styleClass="hidden-xs" headerStyleClass="hidden-xs" columnTitle="Date To"
style="hidden-xs">
</xe:viewExtraColumn>
<xe:viewExtraColumn columnName="$Information"
columnTitle="Information">
</xe:viewExtraColumn>
</xe:this.extraColumns>
</xe:dataView>
My view data source contains same cells where information is empty. Those cells are rendered with style="display:none;".
How can I avoid this attribute and display those empty cells? I'd like not to change my view to fill empty cells with i.e. "-" char
An empty column value gets rendered with style="display:none;":
You can avoid this if you add a custom converter to your column definition and replace an empty value by a space:
<xe:viewExtraColumn columnName="$Information"
columnTitle="Information">
<xe:this.converter>
<xp:customConverter>
<xp:this.getAsString><![CDATA[#{javascript:value == "" ? " " : value}]]></xp:this.getAsString>
<xp:this.getAsObject><![CDATA[#{javascript:value}]]></xp:this.getAsObject>
</xp:customConverter>
</xe:this.converter>
</xe:viewExtraColumn>
It gets rendered to a "normal" grid cell without display:none then:
The code for getAsObject doesn't matter as long as the cell is not editable. So it's OK to just leave the value as it is.
Instead of using a converter to "fake" some content, you could also adjust the css. Just implement
.lotusTable TD {
display: inline !important;
}
in a style sheet resource used in your custom control(s).
So you also won't have to apply a converter to every potentially empty column.

Export Telerik RadGrid with EditMode lines

I need to export a RadGrid table, and it contains several EditMode lines.
I would like to choose which content to export or ideally, if possible, change the lines to
EditMode = false
before exporting, so it looks how I need.
Code Details:
I have a few GridTemplateColumn, here is one of them:
<telerik:GridTemplateColumn
ItemStyle-Wrap="false" UniqueName="DataInicioAtividade"
DataField="DataInicioAtividade" HeaderText="*Data Inicio">
<ItemTemplate>
<telerik:RadDatePicker runat="server" ID="data_inicio" MinDate="1900/1/1">
<DateInput runat="server"
CssClass="date-picker" ID="rad_dateInput_data_inicio"
MaxLength="10" CausesValidation="true" />
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
And a button that simply executes the code:
rgd_grid_naoiniciada.ExportExcel();
The problem is, as it looks, telerik RadGrid exporting just dumps the HTML code of the resulting table to an Excel file.
The behaviour of the component is just like it should be, but the resulting file should have the field values, instead of HTML code containing input fields, links, images of RadCalendar etc...
Thanks in advance.
When you export Set the Templatecolumn values to the text property of Template column and then give ExportOnlyData="true";
This will work for Template columns also now.
In ItemBoundEvent, give the following code.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if ((isExport) && (e.Item is GridDataItem))
{
GridDataItem item = e.Item as GridDataItem;
item["DataInicioAtividade"].Text = ((RadDatePicker)item["DataInicioAtividade"].FindControl("data_inicio")).SelectedDate.ToString();
}
}

Resources