I have a small library (JAR) containing some custom JSF-components. Some of them are composite-components which are completely (or partly) implemented in XHTML files which reside under META-INF/resources/my-components. To use these components from other XHTML-files I have to use the XML-namespace http://xmlns.jcp.org/jsf/composite/my-components.
Other related components in this library are implemented as POJOs using #FacesComponent (and #FacesRenderer). To use these components, I have to use the XML-namespace which is defined at the component's #FacesComponent-annotation (attribute namespace). At this point I can choose whatever I want (like http://my-company.com/my-components).
Since I have not found any possibility to change the namespace-prefix of my composite components, and I do not want to set my POJO's namespace to something like jcp.org (I'm not sure if this is even possible), I have to use two different namespaces to use my components coming from the same library.
But since the namespaces are different only because of an implementation-detail and maybe one component will be realized in a different way in the future, this is not what I want.
So the question is: is there a way to specify the full namespace for my composite-components? Of course, I want to use the same ones which are used for my other components (http://my-company.com/my-components in the example).
Just specify the composite library name in your *.taglib.xml file, below the namespace declaration.
<namespace>http://my-company.com/my-components</namespace>
<composite-library-name>my-components</composite-library-name>
Related
Just like TImageList contains a collection of images, is there a similar component for generic files?
I know I can embed files as resources, but I'd like the convenience of storing different groups of files in different "TFileList" components, and to be able to retrieve files by name or by their position in the list.
Extra points if such a component allowed some sort of design time preview of the file content (just like TImageList lets you see what each image looks like, at design time).
(I come from Delphi where I wrote my own component to do the above, but before I rewrite and port the property editor and all that to Lazarus, maybe there is already something that is tried and tested...)
Thanks!
You can use pre-defined lazarus TFPGList to specialize list of the type, that you want, for example - UTF8String
But, there's no T<>List as a component, only as object.
So, yes, this feature will be useful and i can implement, if have time,
also, there's a very limited RTTI, which has been updated only a few months ago, so you can access Methods and Properties now, so FP is more systemized, than delphi pascal, but also not so enterprise-developed, which limits it to implementations for common opensource and shareware project problems.
Nevertheless, it is more stable and supported, even my friends can contribute.
In JSF sources I found the logic of defining character encoding via facelets.Encoding attribute, which can be available in FacesContext.getAttributes()
See FaceletViewHandlingStrategy#getResponseEncoding method for details. How can I define this attribute for instance of FacesContext? I tried to define it via context-param in web.xml, but it's not working. And also I didn't find any reference about it in JSF documentation.
The main reason why I want do this, it is overriding of javax.faces.request.charset value. I don't want define a special filter for my application the order to define not UTF-8 encoding. Because my application contains a lot of WAR packages inside of big EAR.
We are working on plugin for ReSharper and we want to make our plugin extensible. Seems, we should use ShellComponent attribute to do it but we can not find any examples. Could anybody enplane how to define custom extension point and how to manage extension. Example of code of extension point and extension implementation would be very helpful.
Thanks.
If you're looking to write a plugin that can extend ReSharper, you need to tell ReSharper about the classes in your plugin, by marking them with the [ShellComponent] or [SoutionComponent] attributes. These attributes have different lifetimes - a shell component lasts the lifetime of ReSharper itself, and a solution component is created when a solution is opened and disposed when the solution is closed.
To make ReSharper do something useful with your components, they typically have to implement an interface, such as ICodeCompletionItemsProvider, and sometimes have to use a different attribute, such as [CodeCleanupModule] (which itself derives from ShellComponentAttribute). There are many extension points in ReSharper, and the one that's appropriate for you depends on what you're trying to do - refactoring, unit test provider, code cleanup, code completion items, etc. The devguide provides a good introduction to the more common extension points.
But if you want to make your own plugin extensible, then your component needs to work with a kind of provider pattern, by deferring work to multiple provider instances. For example, code cleanup works by deferring to multiple code cleanup modules, each responsible for cleaning up a different aspect of your code (whitespace, ordering, etc). To do this, your component should take in a collection of providers in the constructor. ReSharper's component model will automatically create a collection of these types and pass them to. More specifically, you should have a constructor that takes an IEnumerable<T> or IViewable<T>, where T is the interface of the provider you're going to define and call. The IEnumerable<T> will give you a simple collection of providers, but IViewable<T> represents an observable collection, and allows you to subscribe to notifications of new providers being made available from the component model.
I am learning to create custom JSF components and have been successful in creating simple ones. One thing I would like to know is that whether there are any naming conventions to be followed while defining <component-family> and <renderer-type> for your component?
For e.g. for combo box the <component-family> is javax.faces.SelectOne. It looks like a Java class but I was unable to find any such class in JSF API.
They do indeed not necessarily represent class names. They are just identifiers. The javax.faces prefix hints in this case merely that it's part of standard JSF API. The same prefix is used everywhere else in standard JSF API. PrimeFaces components use org.primefaces prefix, OmniFaces components use org.omnifaces prefix, etcetera.
You're fully free in choosing your own for your component library. You should only gurarantee that it shouldn't possibly conflict with a 3rd party one which may be mixed by the enduser. Like as with package structure of Java classes, it'd make sense if you choose for com.naveen prefix or whatever what/who represents the owner/developer of the component library.
The same approach as Java packages (and Internet domain names) is a very sensible way of guaranteeing uniqueness (you know, identifiers are supposed to be unique).
See also:
How do I determine the renderer of a built-in component
What is the relationship between component family, component type and renderer type?
Java packages com and org
What I want to do is really similar to this and this except I'm trying to figure out how to put an ArrayExtension inside a module.
I'm trying to get something similar to the way C# extension methods work, that way I can just import the module and I'll have my extra methods. The links I provided show how to extend an existing object, but I haven't been able to figure out how to encapsulate that into a module.
If you're targeting non-browser environments like node.js this will be possible because you will be able to pass references to your module's global members, such as Array, to other modules. Those other modules can then extend the passed in object and/or its prototype with extra functionality which will be only accessible by the calling module. Other modules would have to do the same in order to get these extensions; therefore, conflicts are minimized since imports are explicit.
However, in browser environments this is not the case since there is only one window object and any changes to its members are available everywhere. As soon as any of your modules extended Array those extensions would be available to all other modules -- increasing the possibility for conflicts and making the code harder to reason about.
With that said, there are patterns in JS, and therefore TypeScript, which should accomplish what you want. One such pattern is the 'mixin' pattern which allows you to add on extra functionality on an object instance basis. You could separate re-usable code into mixin modules which could then be applied to an object when needed, or even automatically in constructors. Take a look at this for a decent overview and implementation examples: http://javascriptweblog.wordpress.com/2011/05/31/a-fresh-look-at-javascript-mixins/
If you're trying to extend the built in Array type you can't do that within a module. You're extension will need to live in an ArrayEx.ts file and occur outside of any modules. The reason for that is that if you did it within a module you'd be extending the Foo.Array type which isn't the same as Array.
But you said you just want to be able import the module to have your extra methods show up and all you really need to do is add a /// <reference path='ArrayEx.ts' /> to any file you want the extension methods to be available to. This is essentially the same thing.