I have an properties file in one location (/home/XXXX) and want one of its property acessed in velocity templete in location (/irb/dev4/ccm_wa/cb532/RBAPI-XXX/RBAPI/BA/tools/src/com/gen/tools/build/j2ee/ejb). how do we access them??
I need the below foreach loop to be executed only if the above accessed property returns true
#if( **PROPERTY IS TRUE** )
#foreach ($databaseGroup in ${root.getAllDatabaseGroups().values()})
#foreach ($index in ${databaseGroup.getIndices()})
<resource-ref>
<res-ref-name>${databaseGroup.getResRefPrefix()}${databaseGroup.getTxDs(${index})}</res-ref-name>
<resource-name>${databaseGroup.getResRefPrefix()}${databaseGroup.getTxDs(${index})}</resource-name>
</resource-ref>
In your Template class read the properties file into an Properties object and put this to the context. i would suggest Apache Commons PropertiesyConfiguration for that:
PropertiesConfiguration props = new PropertiesConfiguration("/home/XXXX");
contxt.put("props", props);
in your template file you can now check your properties:
#if($props.getBoolean(propertyName))
Related
I have the following model snippet:
nodeOrigin: types.maybe(types.reference(nodeState)),
node: types.maybe(nodeState),
And I start editing a node by the following function (the original node i saved so it can be used in a undo() function):
startEditing(node) {
self.nodeOrigin = node;
self.node = clone(node);
}
And in my render method the editing node is used like this:
<form className="form">
<TextField margin='dense' value={getStore().node["name"]} />
</form>
But when I change the name and print the content of both the node and the original node, they have both the changed name. NodeOriginal should contain the original name. What am I doing wrong?
types.reference is tied to types.identifier. The thing you probably misunderstand here, is that types.reference references the types.identifier property of the given node and not the node itself.
When you clone you do not alter an id of the original node. types.reference is resolved on the fly from identifier cache by the given id, so it will always reference the node with the given id.
Moreover, given that id cannot be altered after initialization and that it should be unique across the whole node tree, I'd conclude that nodes having types.identifier property are not meant to be cloned with clone utility.
Alternatively, you could take a snapshot of the node you want to clone, manually update types.identifier property and create a new node from that. Something like:
const cloneWithNewId = (node, id) =>
getType(node).create(Object.assign({}, getSnapshot(node), { id }));
im trying to bind an entitySet from a oData-Service to a list.
My code looks like this:
var list = oView.byId("list");
var requestModel = new sap.ui.model.json.JSONModel()
.attachRequestCompleted(function(data) {
var model = new sap.ui.model.json.JSONModel();
model.setData(data.getSource());
list.setModel(model);
});
requestModel.loadData("/sap/opu/odata/sap/XXX_SRV/detailSet?$filter=XXX eq 'XXX'");
My service returns a array of detail-Objects as expected but i can't seem to find a way to bind them to the list.
Thanks
I finally found a solution:
At first i had to create a dummy Path in my list like this:
<Table class="sapUiResponsiveMargin" items="{/dummy}" id="table" width="auto">
When you can bind the url directly to the table:
var url = "/XXX?$filter=XXX eq '" + XXX + "'";
var table = oView.byId("table");
table.bindItems({
path: url,
template: table.getBindingInfo("items").template
});
To get started with the ODataModel try this guide. In general it is very easy.
Instantiate the model like described in the guide.
Set the model to the view.
Make use of the binding syntax in XML views to trigger a request to load your entities.
I am trying to enhance the default Shared/Error.cshtml that comes with the standard MVC template in VS2013. The model is System.Web.Mvc.HandleErrorInfo and I added the following:
#foreach (var key in Model.Exception.Data.Keys)
<li>#key : #Model.Exception.Data[key]</li>
It gives an error in the key in #Model.Exception.Data[key]: The name 'key' does not exist in the current context.
Why and how do I get each value from the dictionary Data?
try this:
#foreach (var key in Model.Exception.Data.Keys)
{
<li>#key : #Model.Exception.Data[key]</li>
}
razor need "{" to know that the code is inside the foreach loop
I have a JSF application where I need to create almost all of the UIComponents dynamically based on certain parameters to the page. The components are created and added to an HtmlPanelGrid. I've been successfully creating HtmlLabel, HtmlInputText, UISelectBoolean, and HtmlCommandButton. Now I need to create an HtmlSelectOneMenu and add it, and I'm having a hard time finding examples that show how to attach the list of items to select.
The selection list is this, where I've made cfaItems a property of my backing bean:
SelectItem[] cfaItems = {
new SelectItem(1, "1"),
new SelectItem(2, "2"),
new SelectItem(3, "3"),
new SelectItem(4, "4"),
new SelectItem(5, "5")
};
The creation of the HtmlSelectOneMenu:
HtmlSelectOneMenu cfaMenu = (HtmlSelectOneMenu)
getApplication().createComponent(HtmlSelectOneMenu.COMPONENT_TYPE);
cfaMenu.setId("cfaMenu");
grid.getChildren().add(cfaMenu);
As best as I can figure it out, I need to create a ValueExpression that would bind the cfaItems list to the cfaMenu but not finding any examples is a problem. I think that I need to do something like this
String menuBinding =
"#{" + beanName + ".cfaItems}";
ValueExpression menuVE = getApplication().getExpressionFactory().
createValueExpression(FacesContext.getCurrentInstance().
getELContext(), menuBinding, String.class);
cfaMenu.setValueExpression("value", menuVE);
But I don't think that's correct. Any suggestions?
You need to create an UISelectItems instance with the given select item array as value and then add it as child of the menu, exactly as you'd do with <f:selectItems> in the view side.
UISelectItems selectItems = new UISelectItems();
selectItems.setValue(cfaItems);
cfaMenu.getChildren().add(selectItems);
I need to modify the T4 template POCO.tt to retrieve the database schema from the EDMX file. I can see the schema stored in an EntitySet tag in the XML. However I cannot find the schema anywhere when using an EntitySet object.
Anyone know where I would find the database schema?
Thanks
UPDATE
I wrote up my findings on this in a blog post:
http://www.ninjanye.co.uk/2011/06/getting-schema-information-from-edmx.html
http://jnye.co/Posts/3/getting-schema-information-from-an-edmx-file-with-poco
I came across this same problem myself.
First you need to retrieve the EntityContainer from the Storage Model Content (edmx:StorageModels) section of the edmx file
At the top of the tt template (after the MetadataLoader is instantiated and the inputFile is declared) add the following code to get the Storage Model Content EntityContainer
StoreItemCollection sic;
loader.TryCreateStoreItemCollection(inputFile, out sic);
EntityContainer sicEntityContainer = sic.GetItems<EntityContainer>().First();
Then from within the foreach (var entity in ItemCollection.GetItems...) loop you can get the current schema with the following
EntitySet eset = sicEntityContainer.GetEntitySetByName(code.Escape(entity), true);
string schemaName = eset.MetadataProperties["Schema"].Value.ToString();
Note: You may have to repeat the get schema code for ComplexType properties lower down in the tt template
I think I misunderstood your question the first time. Have you examined the edmx schema for any clues?
According to this link: http://msdn.microsoft.com/en-us/library/cc982042.aspx
The schema for applications that
target the .NET Framework version 4 is
defined in the
Microsoft.Data.Entity.Design.Edmx_2.xsd
file. The schema for applications that
target the .NET Framework version 3.5
SP1 is defined in the
Microsoft.Data.Entity.Design.Edmx_1.xsd
file.
Those are in %VS100COMNTOOLS%\..\..\Xml\Schemas\ for VS 2010, and %VS90COMNTOOLS%\..\..\Xml\Schemas\ (the 3.5 only) for VS 2008
I'm working with EF6 and wanted to add a summary comment to the classes being generated by the t4 template. After hacking around for a while, I managed to do it by loading the EDMX file and using XPath to find what I needed.
var xmlContent = XDocument.Load(textTransform.Host.ResolvePath(inputFile));
var edmxNavigator = xmlContent.CreateNavigator();
XmlNamespaceManager nsMgr = new XmlNamespaceManager(edmxNavigator.NameTable);
nsMgr.AddNamespace("edmx", "http://schemas.microsoft.com/ado/2009/11/edmx");
nsMgr.AddNamespace("store", "http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator");
nsMgr.AddNamespace("ssdl", "http://schemas.microsoft.com/ado/2009/11/edm/ssdl");
nsMgr.AddNamespace("cs", "http://schemas.microsoft.com/ado/2009/11/mapping/cs");
//This is the loop that came with the default template
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
{
fileManager.StartNewFile(entity.Name + ".cs");
BeginNamespace(code);
var mappingAttribute = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:Mappings/cs:Mapping/cs:EntityContainerMapping/cs:EntitySetMapping/cs:EntityTypeMapping[#TypeName=\"" + entity.FullName + "\"]/cs:MappingFragment/#StoreEntitySet", nsMgr);
var entitySet = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:StorageModels/ssdl:Schema/ssdl:EntityContainer/ssdl:EntitySet[#Name=\"" + mappingAttribute.Value + "\"]", nsMgr);
var actualTableName = (entitySet.SelectSingleNode("#Table") ?? entitySet.SelectSingleNode("#Name")).Value;
var actualSchemaName = (entitySet.SelectSingleNode("#Schema", nsMgr) ?? entitySet.SelectSingleNode("#store:Schema", nsMgr)).Value;
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
/// <summary>
/// Database Object: <#=actualSchemaName#>.<#=actualTableName#>
/// </summary>
<#=codeStringGenerator.EntityClassOpening(entity)#>
See http://brewdawg.github.io/Tiraggo.Edmx/ you can install it via NuGet within Visual Studio and it serves up ALL of the metadata from your EDMX files that Microsoft hides from you, very simple, works great. You want access to all that low level storage information like your property SQL types, the schema, it's all there. You can even use the Sample Windows.Forms app in the github repo to set a breakpoint and examine the data.
Facing this issue a few weeks ago. As a result create Xslt transformation of EDMX to XSD. https://wash-inside-out.blogspot.com/2022/12/edmx-file-to-xsd-with-xslt.html