ColdFusion ORM cannot find CFCs when using virtual directory - orm

I have some entities with relationships:
component name="Store" persistent="true"
{
property name="Products" fieldtype="one-to-many" cfc="Product";
}
component name="Product" persistent="true"
{
property name="Store" fieldtype="many-to-one" cfc="Store";
}
The above code is simplified. My project resided in C:\ColdFusion9\wwwroot\StoreTracker, and everything worked great.
But then I had to move it to a virtual directory. I moved my project to C:\Projects\StoreTracker, but now the ORM does not work anymore with the following error:
Cannot load the target CFC Store for the relation property Store in CFC Product.
Could not find the ColdFusion component or interface Store.
If I fully qualify the name though by using:
property name="Store" fieldtype="many-to-one" cfc="entities.Store";
then the ORM works. Does anybody know why moving it to a virtual directory causes the ORM to search through the wrong folder for persistent entities, and if there's an easier way to change which folder it's searching through so I don't have to fully qualify every relationship?
Edit:
Here is the relevant part in Application.cfc:
this.ormSettings = { cfclocation="entities" };
And the folder structure for the model folder:
C:\Projects\StoreTracker\entities
There are no sub-folders under the entities folder and all my persistent entities are in there.
I was able to get it to work correctly if I add the following line to Application.cfc:
this.mappings["/entities"] = "C:\Projects\StoreTracker\entities";
Though I'm not sure why this works. Without it, CF ORM seems to read the entities just fine if they only have simple properties, but when there's a relationship, it bombs out saying that it can't find the related CFC. Perhaps a bug?

If by virtual directory you mean a virtual directory set up in Apache or IIS, then this makes sense. Those virtual directories exist in the web server, not in ColdFusion. CF has no knowledge of them.
You probably need to create a ColdFusion mapping to your application. I am not sure exactly how your app is structured or where you are putting your ORM objects, but you may want to add something like this to your Application.cfc in the pseudo-constructor area.
<cfset application.mappings["/StoreTracker"] = "C:\Projects\StoreTracker" />
Update: Oh and don't forget to ormReload()

Related

.NET Core Localization Files After Refactoring Class Name

Trying to make sure I'm not missing something. If I have a project with following
/src
/Models
/Foo.cs
/Resources
/Models
/Foo.resx
And everything is working fine via a dependency injected IStringLocalizer<Foo>. If I decided to refactor the class and name it Foobar...it now appears to be fubar because Foo.resx didn't rename.
Is the whole pattern of seperate files for each class/view/razor page not the recommended approach and instead I should just have a global /Resources/StringResources.resx file that I never rename and use via 'marker' class IStringLocalizer<StringResources>?
I kind of liked the organization of separate files, but during early development when names, namespaces, etc. are changing it is quite painful to keep everything in sync.
I kind of liked the organization of separate files, but during early
development when names, namespaces, etc. are changing it is quite
painful to keep everything in sync.
Although it's recommened to put the resource files in the Resource floder to Manage the resource files .You could also try to put .cs file and .resx file together during development,when you modify the name of .cs file, the name of .resx file would be modified
Tried with the minimal codes:
regist the service:
services.AddLocalization();
in controller:
public IActionResult SomeAction()        
{            
var val = _localizer["Constant"].Value;    
......        
}
It would work well no matter you modify the class name or Namespace:
It would work for IViewLocalizer as well

How to register a Property Handler on folders?

I built a virtual filesystem (not a namespace extension) for Windows which acts as a frontend of our document management server consisting of files and folders. In order to be able to display some metadata of the DMS objects in Windows Explorer as additional selectable columns, I successfully provided properties to the Windows Property System by implementing a COM Property Handler. Wheras normal property handlers focus on specific file types for which they feel responsible, my Property Handler adds properties to all files regardless of their type. Because Property Handlers can only be registered on the file type level, I registered my handler for about 30 types under
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers\<.Extension>
However, I did not manage to register the Property Handler for folder objects. Since all objects in our file system are virtual I build the property store (IPropertyStore) by implementing IInitializeWithFile instead of IInitializeWithStream. The properties are requested from our DMS with the path of IInitializeWithFile acting as key and were not read from an objects content. This concept would work for folders as well.
For getting called on folders I tried to associate the handler by registering under different well known identifiers like Folder, Directory, AllFileSystemObjects and * instead of the file extension without success.
I also didn’t find anything in the MSDN documentation regarding this aspect.
Is there a way to register a Windows Property Handler on folders? Or is there some other way to add custom columns to folders in Windows Explorer?
I'm not sure if it is possible to do this.
Property handlers are clearly not the right approach, they are system wide and there can only be one per file extension. They should only be implemented by the software that "owns" the file extension and can parse the file to extract properties.
The old column handlers would have been your best bet (IMHO) but they are officially dead and you already said you can't use them.
Have you considered creating a namespace extension? Either as a root item somewhere (Desktop or My Computer) the way My Documents used to work in 2000/XP or maybe something more along the lines of how OneDrive works?
I'm not sure if desktop.ini files work in the root of a drive but it might be worth looking into. You would then find yourself in the poorly documented land of [.ShellClassInfo] and its CLSID, CLSID2 and UICLSID members. The general idea would be to act as a IShellFolder proxy on top of the "real" IShellFolder so you could create a multiplex property store. I think there are some (undocumented?) property keys you can override to change the folders default columns and tooltips as well.
There is also something called a delegated folder that allows you to play with nested PIDLs but the documentation is once again pretty useless so I'm not sure if this is something worth looking into.
A 3rd option is to pretend to be a cloud storage provider. I don't know if this gets you any closer to your goal and you would still have to implement some NSE bits to get to the point where you can layer yourself on top of the underlying IShellFolder. This feature is rather new and only documented to work on Windows 10.
The inner workings of how Explorer/IShellBrowser is connected to the IShellFolder/IShellView is one of the least documented parts of Windows. There are hundreds of undocumented interfaces. Explorer gives DefView special treatment leaving other 3rd-party implementations out in the cold.
My feeling is that there is no clean solution to implement this on top of a drive letter but you might get lucky, if Raymond Chen drops by he might have some tips for you...

<global namespace> contains definition for __ in multiple code generated files

I just can't get a handle on how to correct this one. It cropped up about a week ago, and I don't know what change I made could have caused this. We use SVN and I rolled back changes I made of possible culprits of these errors but I am still getting the following errors when I build my asp.net webforms project:
The namespace <global namespace> already contains a definition for 'TrxStatus'
The namespace <global namespace> already contains a definition for 'MessageStatusType'
These two errors are repeated 5 times (10 errors total) and the source files are code generated for the loads of webservices we have in the project.
The file names are App_Code.34kjg234jh1.cs (made up, but you get the idea) and at the top of each one it tells me where it is being generated from:
App_Code\App_WebReferences\SomeService\SomeWebService.wsdl
If I go into the .wsdl definition I believe they do all live in the same namespace based off of this line: (Note, I am not a .wsdl wiz, so tell me if I am wrong)
<s:schema elementFormDefault="qualified" targetNamespace="http://www.thirdpartysite.com/Soa/Foundation/">
<s:import namespace="http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd" />
This is an application inherited from our prior developer (its a one developer shop here, so I usually get to poke around in the dark) so I don't know why we have about 7 different web services in the application, all with that namespace definition and ALL with the offending 'TrxStatus' and 'MessageStatusType'.
I don't want to change the namespaces, because it is the right namespace (I believe), but I also need this conflict to go away. I am not sure which direction to go.
I attempted to go into one of the .wsdl files and change TrxStatus to TrxStatus_Whatever but that gave me this error:
Unable to import binding 'MyWebServiceName' from namespace http://www.thirdpartysite.com/SOA/Foundation
Another possible clue is I am getting a ton warnings from the various web services that say something like this:
The 'http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd:SomeElementName' element is not declared.
Any suggestions on possible solutions to this? What is the root cause? Please don't tell me I need to re-write all these services....
I'm by no measure an expert, in fact I do very little ASP.NET & Services.
BUT. It sounds as if there are conflicting imports (i.e usings) that are pulling in types with the same names.
proj1: A.SomeType
proj2: A.SomeType
You can add references to both projects and it play just fine (I believe). But the difficulty comes when you import both namespaces because the type names clash.
You can access the correct type by using the global:: accessor.
You can even use global:: in a using statement.
using A = global::[path to correct project and type here]
Not sure if it'll be much use to you, but there's more info on global:: here:
http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

How to update the JSF2.0 (Primefaces) tooltips dynamically without server restart

I need to update the JSF2.0 (Primefaces) tooltips dynamically without server restart.
Meaning need to find a way where tooltips (atm from properties file) of the a running application can be changed without requiring a server restart.
We are running websphere and deploying a non exploded EAR (can probably convince to deploy exploded war)
Any Ideas or tips please. Thanks you
The value attribute of the p:toolTip component must be an EL expression or a literal text. Usually, one would reference a resource bundle declared using the var attribute of the f:loadBundle tag, in the EL expression for the tooltip.
The underlying resource bundle declared using the basename attribute could be backed by a property file itself (in which case you need to place the property file in the appropriate directory on the classpath), or for that matter it could be a custom ResourceBundle implementation that could read from a properties file (located outside the container), or a database or any store for that matter.
You could therefore change your existing EL expression from the existing one defined as:
<f:loadBundle var="msg" basename="propfile_location" />
to
<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />
In simpler words, you will need to roll your own ResourceBundle class(es) to support the various locales. Needless to state, but you will need to override the ResourceBundle.getObject(java.lang.String) method, as it is invoked by the ResourceBundleELResolver implementation when evaluating the EL expressions referencing ResourceBundles.
Additionally, you will need to ensure that the ResourceBundle.getObject(java.lang.String) implementation of your ResourceBundle will always re-fetch and return the value corresponding to the provided key. Failure to ensure this would mean that the initial value fetched by the resource bundle may be returned on subsequent invocations, especially if you are caching the initial value. You are likely to encounter this behavior even if you deploy an exploded WAR file where you can modify the property file contents without a redeployment of the application, and that is why it is important to use a custom ResourceBundle implementation that does not cache values.

Do i *have* to use ObservableCollection in Silverlight WCF client?

When accessing Silverlight in WCF you get proxies generated with ObservableCollection
Thats fine when you're databinding, but a little clumsy when you're just calling a method. For instance the following service method :
[OperationContract]
public SearchOrdersMsgOut SearchOrders(ShippingStatusType[] shippingStatuses,
string[] orderId)
{
}
gets generated with ObservableCollection. What! They're just parameters. Why would I ever want to 'observe' them?
I'm fine if I have to do this - but it seems like there should be a way to force simple array structures when I know I'm never databinding - especially on input messages.
I'd much rather do this :
searchCriteria.PaymentStatus = new [] { PaymentStatusType.PaymentFailed, PaymentStatusType.Unpaid };
than this :
searchCriteria.PaymentStatus = new ObservableCollection<PaymentStatusType> { PaymentStatusType.PaymentFailed, PaymentStatusType.Unpaid };
Is there a way?
PS. I do actually use a SearchCriteria object for my search criteria - but I simplified for this example wondering if parameters were handled differently.
You can do this service-wide, but not on a per-method basis. In the Add Service Reference dialog box, click on "Advanced", and choose "System.Array" for the Collection type. But I'm not aware of any way to do it method-by-method, i.e., use array for some methods and ObservableCollection for others.
OK here's a bizarre twist after having got used to using ObservableCollection for my silverlight clients.
I tried to return a Linq2XSD object from my WCF service - and then suddenly low and behold it changed all the ObservableCollection<T> properties into simple arrays [].
I thought it was something specific to Linq2XSD - so I tried just adding a simple XTypedElement property to the service definition:
public XTypedElement[] PipelineLogs { get; set; }
This triggers [] instead of ObservableCollection<T> in the generated proxy - where normally string[] would become ObservableCollection<string>.
Don't ask me why!
I've since removed it because I actually prefer ObservableCollection<T>. I just thought the observation might interest someone with a similar problem - especially if anyone can explain why its doing it!
Ended having the OPPOSITE problem when VS2010 RC had a bug preventing it from generating ObservableCollections.
Fortunately there are two workarounds:
Option 1:
Believe the best option – this is to update the “Reference.svcmap” file for the impacted service reference. In Solution Explorer, select “show all files” and expand the impacted reference node. There you will find the “Reference.svcmap” file, double click to open into the editor. For the observablecollection mapping, you should see currently something like this:
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1" Category="List" />
Change TypeName value to include the Silverlight assembly “System.Windows” – like below :
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1, System.Windows" Category="List" />
Option 2: Generate your
Reference.vb/.cs service reference
proxy code files outside of VS by
using directly SLSvcUtil.exe. Example
of running the tool via command-line
where it will address the
observablecollection issue code
generation issue: "C:\Program Files
(x86)\Microsoft
SDKs\Silverlight\v3.0\Tools\SlSvcUtil.exe”
/r:"C:\Program Files (x86)\Microsoft
Silverlight\3.0.40818.0\System.Windows.dll"
/ct:System.Collections.ObjectModel.ObservableCollection`1
http:///Service1.svc
This will by default generate a C#
version of your service reference
proxy code. If you need to generate a
VB version, you can pass a
“/Language:VB” switch.
Another thing to check (if you want ObservableCollection<T> but you're getting T[]) - is the Reference.svcmap file
Make sure that you have included 'System.Windows' in the typename.
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1, System.Windows" Category="List" />
and not
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1" Category="List" />
I'm guessing perhaps it can't find the Dll and defaults to []