I have created a new component and I want to be able to pass an image from a static resource and a custom label via aura:attribute. This is what I tried and it does not work. How can I make the image/text to show?
<aura:attribute name="profileImage" type="string" default="Standard_Profile" />
<aura:attribute name="categoryName" type="string" default="Standard_Name" />
<img src="{!$Resource + !v.profileImage}" alt="profile pic"/>
<h3>{!$Label.'categoryName'}</h3>
I am very new to Salesforce.
Map the values from your custom label and static resource as default values in the attributes and use it in the code
<aura:component implements="flexipage:AvailableForAllPageTypes">
<aura:attribute name="profileImage" type="string" default="{!$Resource.profileImage}" />
<aura:attribute name="categoryName" type="string" default="{!$Label.c.categoryName}" />
<!-- Stand-alone static resources image file-->
<img src="{!v.profileImage}"/>
<!-- custom label -->
<div>
{!v.categoryName}
</div>
</aura:component>
Related
<aura:component implements="force:appHostable,lightning:isUrlAddressable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" controller="AccountController" access="global" >
<aura:attribute type="campaign[]" name="acctList"/>
<aura:attribute name="mycolumns" type="List"/>
<aura:handler name="init" value="{!this}" action="{!c.fetchAcc}"/>
<lightning:datatable data="{! v.acctList }"
columns="{! v.mycolumns }"
keyField="id"
hideCheckboxColumn="true"/>
</aura:component>
Could you use
<aura:unescapedHtml value=""/>
I`m trying to create calendar with popup form
<record id="view_sale_order_lines_calendar" model="ir.ui.view">
<field name="name">sale.order.line.inherit</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<calendar string="Transfers" **event_open_popup="True"** color="state" date_start="date_start" date_stop="date_stop">
<field name="order_id"/>
<field name="departure_bcs"/>
<field name="destination_bcs"/>
<field name="state"/>
</calendar>
</field>
</record>
I cant find any documentation, and for example take code of Meetings Calendar
When i click on calendar line i get popup window with next error:
AccessError No value found for sale.order.line('58',).name
ODOO 8.0.1
You must use event_open_popup="%(my_module.my_form_view)s"
I am using a simple xml file.
<COMPANY>
<EMPLOYEES>
<EMPLOYEE>
<NAME>BOB</NAME>
<EMPID>51211</EMPID>
<SEX>M</SEX>
<DOB>10-1-1982</DOB>
<DOJ>12-7-2001</DOJ>
</EMPLOYEE>
</EMPLOYEES>
</COMPANY>
The xml booster meta definition file for the same is as below
<SYSTEM NAME="testmeta" >
<CCONFIG MAXLEN="100"
ARRAYSIZE="5"
FLATMODE="TRUE"/>
<ELEMENT NAME="COMPANY" TAG="COMPANY" MAIN="TRUE" >
<FIELDS>
<FIELD NAME="EMPLOYEES" REFTYPE="EMPLOYEE" MODE="DEFAULT" />
</FIELDS>
<FORMULA>
<ENCLOSED NAME="EMPLOYEES" >
<META NAME="COMMENT" >Target field is EMPLOYEES</META>
<REPEAT TARGET="EMPLOYEES" ATLEASTONE="TRUE" >
<ELEMENTREF NAME="EMPLOYEE" />
</REPEAT>
</ENCLOSED>
</FORMULA>
</ELEMENT>
<ELEMENT NAME="EMPLOYEE" TAG="EMPLOYEE" >
<FIELDS>
<FIELD NAME="NAME" TYPE="STRING" />
<FIELD NAME="EMPID" TYPE="INTEGER" />
<FIELD NAME="SEX" TYPE="STRING" />
<FIELD NAME="DOB" TYPE="STRING" />
<FIELD NAME="DOJ" TYPE="STRING" />
</FIELDS>
<FORMULA>
<CONCAT>
<ENCLOSED NAME="NAME" >
<META NAME="COMMENT" >Target field is NAME</META>
<PCDATA TARGET="NAME" />
</ENCLOSED>
<ENCLOSED NAME="EMPID" >
<META NAME="COMMENT" >Target field is EMPID</META>
<PCDATA TARGET="EMPID" />
</ENCLOSED>
<ENCLOSED NAME="SEX" >
<META NAME="COMMENT" >Target field is SEX</META>
<PCDATA TARGET="SEX" />
</ENCLOSED>
<ENCLOSED NAME="DOB" >
<META NAME="COMMENT" >Target field is DOB</META>
<PCDATA TARGET="DOB" />
</ENCLOSED>
<ENCLOSED NAME="DOJ" >
<META NAME="COMMENT" >Target field is DOJ</META>
<PCDATA TARGET="DOJ" />
</ENCLOSED>
</CONCAT>
</FORMULA>
</ELEMENT>
</SYSTEM>
Generated a .c and .h file for the same using xmlbooster lite using following command
xmlblit.exe -C testmeta.xmlb
Now in my application in main function i m calling accept_COMPANY function and passing S_XMLB_CONTEXT context object. Function succeeds but when i print each employee value using
printf("%s, %d, %s, %s, %s", En->aNAME,
En->aEMPID,
En->aSEX,
En->aDOB,
En->aDOJ);
printf("\n");
i am getting junk characters printed, even for the integer aEMPID value.
I am using Visual studio 2010 to compile and run the C program.
Tried both Unicode and MultiByte project but no luck in getting the correct values.
I am getting output as
UOB, 78, M, j0-1-1982, 1t-7-2001
After debugging the generated .c file found that, the generator is setting unwanted values for PCDATA type field. For e.g. for NAME field after retrieving the name from XML, the code has the following statement
/* Regexp */
if (strlen(obj->aNAME) > 0)
(obj->aNAME)[0] = 'U';
Anyone faced similar situation?
Wrote to xmlbooster support got the following reply.
XMLBooster Lite only support Java ; C is only provided for evaluation purposes, as values are scrambled as you’ve noticed in your sample programs and in the generated code. You need to purchase XMLBooster Pro to generate production-level parsers in C.
Got the answer, hope this helps others too who are experimenting.
I have 2 classes like this :
Message(id, title, content)
MessageEmployee(id, messageId, employeeId, readFlag)
and 2 tables like this :
MESSAGE(mess_id, mess_title, mess_content)
MESSAGE_EMPLOYEE(mess_empl_id, mess_id, empl_id, read_fg)
Mapping files :
<hibernate-mapping package="core">
<class name="Message" table="MESSAGE">
<!-- class id -->
<id name="id" type="int" column="MESS_ID" length="11">
<generator class="native"/>
</id>
<property name="content" type="string" column="MESS_CONTENT" />
<property name="title" type="string" column="MESS_TITLE" />
</class>
</hibernate-mapping>
<hibernate-mapping package="core">
<class name="MessageEmployee" table="MESSAGE_EMPLOYEE">
<!-- class id -->
<id name="id" type="int" column="MESS_EMPL_ID" length="11">
<generator class="native"/>
</id>
<!-- employee -->
<many-to-one name="employee" class="core.Employee"
column="EMPL_ID" cascade="save-update,merge" lazy="false" />
<!-- message -->
<many-to-one name="message" class="core.Message"
column="MESS_ID" cascade="save-update,merge" lazy="false" />
<property name="readFlag" type="character" column="READ_FG" />
</class>
</hibernate-mapping>
Here is my problem :
let's say I already have a message in database, and I want to create a messageEmployee and save it.
Code snippet :
Message sent = new Message(content, title);
Employee e = employeeDao.loadEmployeeWithId(Integer.valueOf(to));
messageDao.merge(sent)
MessageEmployee m = new MessageEmployee(sent, e, null);
m.setReadFlag('N');
messageEmployeeDao.mergeMessageEmploye(m);
When I merge(messageEmployee), it creates a new message and a new messageEmployee in database, but I don't want it to create a new message.
I'm quite sure my mapping is wrong since I am no expert, so what could I change to get the behaviour I want ?
It will create a new Message object because you are not providing id in your message object sent. When you execute messageDao.merge(sent), the sent object doesn't have and id to merge with. It is pure transient object. Try loading it from database like Employee.
Hello Stack Overflow Experts, i have need of your expertice:
I am trying to use Hibernate on an Existing DB.
Currently im trying to load a User object and a list of UserData objects that go along.
in the DB the (simplified) layout is
| User | | UserData |
---------------- -----------------------------------
uid | username | | uid | parentuid | field | value |
So each User object matches all the UserData objects where UserData.parentuid = User.uid.
My User class mapping file
<class name="com.agetor.commons.security.User" table="ac_users">
<id name="uid" column="uid" type="long" >
<!--<generator class="native"/>-->
</id>
<property name="username" column="username" />
<list name="fieldData" cascade="all">
<key column="parentuid" not-null="true" />
<index column="parentuid" />
<one-to-many class="com.agetor.commons.fields.FieldData"/>
</list>
</class>
Mu UserData mapping file
<class name="com.agetor.commons.fields.FieldData" table="ac_userdef_data">
<id name="uid" column="uid" type="long" >
<!--<generator class="native"/> -->
</id>
<!--<property name="parentuid" column="parentuid" /> -->
<property name="fieldname" column="fieldname" />
<property name="value" column="value" />
</class>
So far i have tried many different configurations and all of them have had various degrees of failue. The code pasted here, does not work.
The parentuid property is commented out, because Hibernate gives a "Repeated column in mapping" error otherwise.
Currently there is still a "Repeated column in mapping" on the uid field, i use for <list-index />
I do not understand where i specify that UserData.parentuid is the foreign key and that the list should use User.uid as key.
I hope someone is able to help.
When you define both a One-To-Many and a Many-To-One, does this not make it Bi-Directional?
The current working model, is Unidirectional and UserData does not have a reference to User. Your suggestion fails, because Hibernate could not find a get or set method for User on UserData.
Is it implied that, this code uses User.uid as a key and matches this against the UserData.parentuid column? Or is this fact specified somewhere else?
<list name="fieldData" inverse="true">
<key column="parentuid" not-null="true" />
<one-to-many class="com.agetor.commons.fields.FieldData"/>
</list>
I am still learning Hibernate and working my way through documentation and examples i can find.
Try this (drycode):
<class name="com.agetor.commons.security.User" table="ac_users">
<id name="uid" column="uid" type="long" >
<!--<generator class="native"/>-->
</id>
<property name="username" column="username" />
<list name="fieldData" inverse="true">
<key column="parentuid" not-null="true" />
<one-to-many class="com.agetor.commons.fields.FieldData"/>
</list>
</class>
<class name="com.agetor.commons.fields.FieldData" table="ac_userdef_data">
<id name="uid" column="uid" type="long" >
<!--<generator class="native"/> -->
</id>
<many-to-one name="user" class="com.agetor.commons.security.User" fetch="join">
<column name="parentuid" not-null="true"/>
</many-to-one>
<property name="fieldname" column="fieldname" />
<property name="value" column="value" />
</class>
If it works, try adding the index and cascade stuff that I left out.
cheers,
mitch
I think you're close, but List is probably not the data structure you want in your new User class. A list implies an ordering of the child elements, which the tables don't seem to have. If you have an indexed collection like a list, the data has to have a separate column that provides the index, hence the "repeated column in mapping" issue.
The rules of thumb I use are - each mapping should include an entry for each member of the class it is mapping. So for instance your User class should have an entry for its collection of FieldData, but your FieldData mapping does not need an entry for parentuid, since that column doesn't map to an element of the FieldData class - it's just used to put the FieldData within the collection in the parent object.
If the User object really does contain an ordered collection of FieldData, then use a set instead. On the other hand, I think it's more likely you'd want a map of FieldData instead, using the 'field' name as the index. Then the FieldData class doesn't need to map the 'field' column and won't have that as a member, it'll just have the value (and any other fields from this table - of course if there really is only one column left to map, you might just end up with a map of strings to strings.
This is the latest development on this problem. This configuration can succesfully load from the Database. Saving does not work.
I have decided to alter the Database design instead, so im posting this here for reference for others, before i abandon this approach.
<class name="com.agetor.commons.security.User" table="ac_users">
<id name="uid" column="uid" type="long" >
<generator class="increment"/>
</id>
<property name="deleted" column="deleted" />
<property name="username" column="username" />
<property name="password" column="passwd" />
<property name="disabled" column="disabled" />
<property name="lockout" column="lockout" />
<property name="expires" column="expires" />
<bag name="fieldData" lazy="extra">
<key column="parentuid" not-null="true" />
<one-to-many class="com.agetor.commons.fields.FieldData"/>
</bag>
<bag name="groups" table="ac_group_rel" access="field" lazy="extra">
<key column="useruid"/>
<many-to-many column="groupuid" class="com.agetor.commons.security.Group"/>
</bag>
<join table="ac_userdef_data" optional="true" fetch="join">
<subselect>
select
*
from
ac_userdef_data data
where
data.objectname = 'user' and
data.fieldname = 'firstname'
</subselect>
<key column="parentuid" />
<property name="firstname" formula="(select data.value from ac_userdef_data data where data.fieldname = 'firstname' and data.uid = uid)"/>
</join>
<join table="ac_userdef_data" optional="true" fetch="join">
<subselect>
select
*
from
ac_userdef_data data
where
data.objectname = 'user' and
data.fieldname = 'lastname'
</subselect>
<key column="parentuid" />
<property name="lastname" formula="(select data.value from ac_userdef_data data where data.fieldname = 'lastname' and data.uid = uid)"/>
</join>
</class>
-->
<list name="fieldData" cascade="all">
<key column="uid" not-null="true" />
<index column="parentuid" />
<one-to-many class="com.agetor.commons.fields.FieldData"/>
</list>
Try this , i just changed key coloumn as parentuid to uid.(And better use set in hibernate mappings)
cheers,
Nagendra Prasad..