XML Serialize with catel - catel

Is it neccessary to have the complete namespace in every model I save to xml.
<MyModel xmlns="http://schemas.datacontract.org/2004/07/MyProject.Models">
Is it possible to disable this?
and is it possible to save a property of this model as attribute instead as element?
<MyModel MyProperty="5" >
<AnOtherProperty>10</AnOtherProperty>
</MyModel >

Set the OptimalizationMode to XmlSerializerOptimalizationMode.PrettyXml.

Related

Change custom entity properties programmatically with hook_entity_presave in Drupal 8

I created a custom entity with a string property qst_type. I would like to change this property programmatically before saving. I think you should use the hook_entity_presave or hook_ENTITY_TYPE_presave. Unfortunately I can not change this property with this hook.

Is there a way to use a javascript object as a custom control property?

I'm currently building a custom control to be used as an application's view navigator (classic OneUI style). First of all: this is a 8.5.3 based project, and unfortunately there's no way to use Extlib stuff or other extensions / plug-ins. So we have to build all the tricky stuff ourselves using only what came "out-of-the-box" with 8.5.3.
I'd llike to build my navigator using a repeat control containing <xp:link> controls. Datasource could be an array of javascript objects where each single object would look like this:
var navEntry = {"entryLabel" : "label-of-link",
"entryTarget" : "target-url-of-link",
"entryStyle" : "style-to-emphasize-selected-link"}
Each array element then would describe a single navigator entry.
Since the navigator will be used in all possible "DominoView" Xpages it yould make sense to build the array of JS objects at the Xpage level and then pass that info into the custom control.
I'm aware that there are multiple ways to do this, and one could be "Custom Control Properties". If there was a way to pass my JS object array.
(Hope I could make clear what I'm trying to do here...)
That object looks like a HashMap to me really. You should be able to pass that in to a custom control via custom property if you use the type java.util.HashMap I'd think. You'll need to type it in I'm sure. I've passed custom objects in by using java.lang.Object.
The custom control will get loaded during the Page Load event, and usually properties have to be available at that point. If they're loaded during the Render Response phase, that's too late. So your SSJS object will need to be Compute on Page Load.
To use contents of a repeat control, you would need to set repeatControls=true, otherwise the repeat is only built during render response. Until then it's just a single set of controls with no data in them. However, Im pretty sure repeatControls="true" means you only get the number of rows you define. You can't change it via a pager.
You can manually define the type of the custom property. For a standard SSJS Object you use "com.ibm.jscript.std.ObjectObject", for a SSJS Array you use "com.ibm.jscript.std.ArrayObject" etc. As editor for the custom property, I set the string editor ("String value").

compute dynamically the allowDelete property of file download xpages

I am using a file download control and I would like to set the value of the "allowDelete" property dynamically depending on whether the document is in edit or read mode. However, this
property is computed onload of the page. I tried calling the function "setAllowDelete(boolean)" on the onclick event of a button or the "beforeRenderResponse" event of a custom control and a partial or full update to change the value of the property, but it didn't change.
Do you know if there is a way to do this?
Thanks a lot in advance!
I have encountered the same problem. There are two options to workaround it.
1) To use two controls, one with deletion enabled, the other with deletion disabled, and use rendered properties according to edit state (or user role).
2) Render download controls by your own, as data table or repeat. However, this solution has its own problems, too.
Have you tried just calculating the property like this?
<xp:fileDownload .... >
<xp:this.allowDelete><![CDATA[${javascript:
return document.isEditable()}]]>
</xp:this.allowDelete>
</xp:fileDownload>

libary control for Xpages and using ssjs for defaultvalues/validators

I' working on a libary control for Xpages and need some help in creating.
I would create an control wich reads a configuration file and creates controls in a table, controls like Editboxes, checkboxgroups and so on.
Ive Build my control like Keith Strickland
in his Bolg entry
http://xprentice.gbs.com/A55BAC/keithstric.nsf/default.xsp?documentId=82770C11FA7B9B21852579C100581766
so and now to my queststion:
I would store in my configuration ssjs code for computing a defaultvalue or an validation
but how could I compute the ssjs?
the automatic generated code from the Designer uses a PageExpressionEvaluator Object but I couldent create one by my self.
someone an Idea?
You can use the ExpressionEvaluatorImpl class instead:
com.ibm.xsp.page.compiled.ExpressionEvaluatorImpl( facesContext )

Problem of viewstate in MVC Architecture?

We add mutiple data of text boxes to gridview that would not update database untill user press add button...here i had tried to use viewstate but the it become null when any other event occures in MVC Arch...so this the problem.can i use dataset...if yes than how???
thank you in advance...
You don't use viewstate in MVC. You can use DataSet of course, but controls that relied on viewstate in webforms will not work.
MVC Do not have viewstate and session but you can use TempData Object instead of viewstate. in your controller you can bind like this TempDate["MyKey"]="My Value" and in the next request you can get your value in action like String s=TempData["MyKey"]
I recommend you to use strongly typed views. Here you can attach you model properties with the view elements, so that when you post back, the model object will contain all the posted values.
You can also use Display Templates, to iterate the test boxes and attach / pass model properties

Resources