I have made a utility custom control to have a quick, generic view. the custom control has as properties a property names collection which is of type object and received an arraylist of java objects (e.g. a Customer object).
Then on the cc a repeat control is using this:
<xp:repeat id="rptObjects" var="obj" indexVar="idx" value="#{javascript:compositeData.collection}" >
I would like to make the columns more dynamic. So I defined a new property called linkName, also of type object.
The in my repeat control I have setup a div with a xp:link control:
<xp:link escape="true" text="#{javascript:compositeData.linkName}">
However I am struggling on the page that contains this cc to compute the value for the linkName property.
If for example I would like to use the name field on a Customer java object how should I compute the valeu for the linkName property?
on my cc I set the text for the link:
<xp:link escape="true">
<xp:this.value><![CDATA[#{javascript:return compositeData.pageLink + "?unid=" + obj.unid}]]></xp:this.value>
<xp:this.text><![CDATA[#{javascript:var lbl = compositeData.linkName;
obj[lbl]}]]></xp:this.text>
</xp:link>
on my xpage i could set:
<xc:ccUtilsGenericView pageLink="customer.xsp"
header="Customers" icon="fa fa-user" linkName="custName">
Related
I've seen a lot of examples of using UpdateExpression to update attributes using the updateItem method. However, I still don't understand how to update multiple attributes in DynamoDB at the same time dynamically.
I am trying to update AND rename multiple attributes in the same updateItem call.
I understand that this requires a REMOVE of the old name and a SET of the new name. I have these names in hashedId's of objects, but won't have them until runtime. So my question is how do I use UpdateExpression with variables and not a hard-coded String?
All the examples I have seen use hard-coded UpdateExpressions.
can't update item in DynamoDB
Dynamo DB : UpdateItemSpec : Multiple Update Expression - Not Working
DynamoDB update Item multi action
How to rename DynamoDB column/key
I am working in Java.
It seems very odd to me that I haven't been able to find an example of this... which leads me to believe I am doing something wrong.
Thanks for the help!
You have to build the update expression string dynamically based on the attribute names and values that you receive at runtime. I do exactly this. I'm not working in Java, but here is some pseudo code (with a Ruby bias) example for you that dynamically builds the update expression string, the expression attribute names hash, and the expression attribute values hash. You can then plug in these 3 things into the update_item method:
update_exp_set = [] //array of remove expression snippets
update_exp_remove = [] //array of update expression snippets
exp_attribute_names = {} //hash of attribute names
exp_attribute_values = {} //hash of attribute values
// Iterate through all your fields and add things as needed to your arrays and hashes.
// Two examples are below for a field with the name <fieldName> and value <fieldValue>.
// You'll need to convert this to Java and update it to make sense with the AWS Java SDK.
// For a given field that needs to be updated:
update_exp_set << "#<fieldName> = :fieldValue" //add to array of set expression snippets
exp_attribute_names["#<fieldName>"] = "<fieldName>" //add to hash of attribute names
exp_attribute_values[":<fieldValue>"] = "<fieldValue>" //add to hash of attribute values
// For a given field that needs to be removed:
update_exp_remove << "#<fieldName>"
exp_attribute_names["#<fieldName>"] = "<fieldName>" //add to hash of attribute names
// Use your snippets to create your full update expression:
update_exp_set_clause = ""
update_exp_remove_clause = ""
if update_exp_set.length != 0 //check if you have something to set
update_exp_set_clause = "SET " + update_exp_set.join(',')
end
if update_exp_remove.length != 0 //check if you have something to remove
update_exp_remove_clause = "REMOVE" + update_exp_remove.join(',')
end
final_update_exp = update_exp_set_clause + " " + update_exp_remove_clause
Does this help?
I'm trying to search value inside Corda unconsumed states on a collection Field.
I'm able to search on String field using -
Field uniqueAttributeName = MySchema.PersistentIOU.class.getDeclaredField("fieldname");
CriteriaExpression uniqueAttributeEXpression = Builder.equal(uniqueAttributeName, "valueToSearch");
QueryCriteria customCriteria = new QueryCriteria.VaultCustomQueryCriteria(uniqueAttributeEXpression);
result = rpcOps.vaultQueryByCriteria(customCriteria, MyState.class).getStates();
Above worked fine when "fieldname" is String but I have another field which is List and I'm not sure how to search inside List for a specific value.
Please assist.
After a quick chat with #Roger3cev, we think the best way is to amend your ORM wrapper such that you have a parent - child relationship between the state and the list of fields you want to have in that list. Once you do this, you can use the JDBC connection available to you to query against the child state and then use the relationship to the parent to get the Corda state.
I'm developing a bookstore in mule esb. When I check the quantity from a book order is available with the database, I want to set a property from payload. The payload has several properties from the book (isbn, quantity, prize, avalability), so the last one in this case I want to set to true (is attribute boolean type).
Is there any way to do that with a connector?
not really sure what you're trying to do but...
To change the payload of a message there several ways the easies one being just using a MEL expression.
Say your payload is a map(for you say you toke it from the DB) then you could just do:
<expression-transformer expression="#[payload['avalability']='your value']"
Now you say you wanted that value to be true then the code should look like:
<expression-transformer expression="#[payload['avalability']=true]
MEL will put a boolean true for you there.
Finally to update the DB you should:
<db:update config-ref="Database" bulkMode="true" doc:name="insert contacts to Database">
<db:parameterized-query>
UPDATE books
SET 'avalability' = #[payload['avalability']]
WHERE 'isbn'= #[payload['isbn']]
</db:parameterized-query>
</db:update>
If you want more example about working with DB please check:
https://www.mulesoft.com/library#!/?types=template&filters=Database
You can set the propertyName dynamically using:
#[message.outboundProperties.propertyName]=any value
I am currently trying to get the current order of columns in a PrimeFaces datatable whenever a user reorders them. Since the server-side event does not provide any parameters, I decided to use a JavaScript handler to do so.
function onColumnReorder(glossary) {
var sortedColumnNames = ...
}
"glossary" is my datatable widget variable. Question is: how do I now retrieve the column names in their current order? Please note that I'm not talking about table data sorting, but just about the current order in which the columns appear in the table (left to right) - which may change of course, since "draggableColumns" is set to true.
Thanks for any advice and best regards
Pascal
First define colReorder AJAX event on datatable:
<p:ajax event="colReorder" listener="#{myBean.onColReorder}"/>
In onColReorder method find your datatable by id with UIViewRoot#findComponent() method. After you found your DataTable object it is easy. Use getColumns() method to get list of columns in onColReorder():
FacesContext fc = FacesContext.getCurrentInstance();
DataTable myDatatable = (DataTable) fc.getViewRoot().findComponent("your_datatable");
List<UIColumn> columns = myDatatable.getColumns();
var th =$(myTableWidgetVar.jqId).find('.ui-state-active');
returns you th with id myTableId:myColumnId, so you know which column has sorting enabled.
You can read now the triangle component:
th.find('.ui-sortable-column-icon');
And check which class it has defined:
'ui-icon-triangle-1-n' for sorting ascending
'ui-icon-triangle-1-s' for sorting descending
You'll have server callback on sort order change if you use LazyDataModel.
If a have a Java object (lets say a User object), and I use velocity to template the page
so I can access a field in the user object like ${user.id}, is there an easy way to convert this into a javascript object (so I can access the fields of the User object)?
I can assign a value to javascript variable like
var id = "${user.id}";
but if i do
var user = "${user}";
this isn't true:
id == user.id;
And I would rather not have to do
var user = { id: "${user.id}" ...}
Maybe you should transform your user object to a JSON.
You can create a utility method that uses reflection and gets each attribute from an object and put in a String. Maybe you can create an annotation to mark which attributes should be included in the JSON.
This way you send to your template something like this
"{id: '1', name:'stevebot'}"
And in you velocity file
var user = ${user};