Hiding/Displaying subcomponents in JSF - jsf-2

We are using Primefaces library for development of JSF components in our application.
I need different subviews(subcomponents) to be embedded in primary views(components).
For example : I need to embed securityXXX.xhtml in both clientXXX.xhtml and marketXXX.xhtml.securityXXX.xhtml itself contains sub-menus(Example : checkbox,drop-down etc).
securityXXX.xhtml is already embedded in clientXXX.xhtml.Now I need to embed securityXXX.xhtml in marketXXX.xhtml but I need to introduce a new sub-menu in securityXXX.xhtml which is required in case of marketXXX.xhtml but not in clientXXX.xhtml.
Is there any way I can hide/show sub-menus in securityXXX.xhtml and display same in clientXXX.xhtml and marketXXX.xhtml according to my need.Can securityXXX.xhtml be re-usable?
I know one of the rendered and visible attributes can be useful for this.Please correct me if I am wrong.I am new to JSF.Please provide me a demonstration/example if possible

Related

How can I see details to grid in Vaadin flow?

In my Vaadin flow project, I have a grid and I set some items but it shows like grid data items
I want a decent format that a user can see specific details not like. Any idea or is there any component in vaadin to make this pretty?
There are two options to do that:
provide a better ValueProvider than the .toString(), that is used in your property right now. E.g.
grid.addColumn(person -> Integer.toString(person.getYearOfBirth()))
.setHeader("Year of birth");
TemplateRenderer: You can provide a "complex" HTML structure where to place content. The docs contain an example: https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/components/tutorial-flow-grid.asciidoc#using-template-renderers E.g.:
grid.addColumn(TemplateRenderer.<Person> of("<b>[[item.name]]</b>")
.withProperty("name", Person::getName)).setHeader("Name");

Import Umbraco property editor

We have site where a user went to the Data Types, saw we had a Content Picker data type using "(Obsolete) Content Picker" (Umbraco.ContentPickerAlias) and changed it to Umbraco.ContentPicker2
Our code relies on the obsolete one currently and now he cannot set the content we want him to.
Is there a way to recreate/reimport the Obsolete property editor into Umbraco?
On the Data Types node you can click on the ... and create a 'New data type' - then select the obsolete one to create it again.
But in theory, I believe you could just do the opposite of what the user did, on the ContentPicker click edit and pick the property editor from the dropdown if available?
Within the umbracoSettings.config file, there is a property you can create/set to true that will make obsolete data types become available to use against data types
<showDeprecatedPropertyEditors>true</showDeprecatedPropertyEditors>

Umbraco, how to add onChange functionality on dropdown content backoffice?

I am having one document type which contains a dropdown list, I need to add a couple of things in it:
I need to display the Database table names in drop-down dynamically.
On the change of dropdown option, i need to display the selected table columns names in another drop-down.
Are above things possible by using only existing data types or it will require creating a custom template using razor syntaxes (if it is so then how the template will display directly in the back office content node?)
Can you please provide your views and any links for code/tutorials?
screen shot of content form
If this is for the back office, you will need to do it in HTML and Angular, with an API controller to handle the DB lookup stuff.
As far as I'm aware, there's nothing built in to do dropdowns that depend on each other, so you'd have to create a new DataType to do it.
The process is to long to detail here, but here are some useful links on creating custom DocTypes in Umbraco 7.
https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/
http://velstand.info/tips/umbraco/to-create-a-datatype-by-using-external-data-sources/
https://24days.in/umbraco-cms/2016/custom-property-editor-tutorial/

Passing contextual info to Views in ASP.NET MVC

I wonder - what is the best way to supply contextual (i.e. not related to any particular view, but to all views at the same time) info to a view (or to master page)?
Consider the following scenario.
Suppose we have an app that supports multiple UI languages. User can switch them via UI's widgets (something like tabs at the top of the page). Each language is rendered as a separate tab. Tab for the current language should not be rendered.
To address these requirements I'm planning to have a javascript piece that will hide current's language tab on the client. To do this, I need current's language tab Id on the client. So, I need some way of passing the Id to master page (for it to be 'fused' into the js script).
The best thing I can think of is that all my ViewModels should inherit some ViewModeBase that has a field to hold current language tab Id. Then, whatever View I'm rendering, this Id will always be available for the master page's hiding script.
However, I'm concerned that this ViewModelBase can potentially grow in an uncontrolled fashion as number of such pieces of contextual info (like current language) will grow..
Any ideas?
If this contextual information is needed by all views then having a base view model seems like a good solution. The question is where to populate this information to avoid cluttering all your controller actions. A custom action filter seems like a good place. In the OnActionExecuted method you could get the view model returned by the controller action and populate the contextual part if it derives from the base type.
Another option is to put the contextual information into the ViewData (strongly typed views can also use ViewData) but personally I hate having magic strings and doing casting in my views (this could be overcome by using HTML helpers that will handle this ViewData).
If you think that ViewModeBase will grow to much you can also have viewmodels implement an interface.
The View or Partial can have the type of that interface.
Thats especially usefull if only some pages have that functonality.

MVC reusable propertygrid

In my web application framework (currently WebForms) I have a control that behaves like a classic propertygrid. It is initialized with an object ID (database key), then it reads metadata to determine the type of the object and the attributes of the object. It displays the attributes, string attributes as textboxes, bool attributes as checkboxes, enum attributes as dropdown lists. On page submit there is a method of the control ctrl.SaveData() that saved the changed attribute values back to the database.
The WebForm control tree and event model supports this approach quite nicely. Now I am asking myself if it is possible to achieve a similar solution for ASP.NET MVC. The main objective is to have a generic, reusable component that can be applied in a variety of situations with not much hassle. Additionally the solution must be flexible enough to put multiple instances of the component for multiple objects on a single page. Here the auto-generated WebForms HTML IDs also helped.
I am very curious about your ideas! Thanks a lot for answering!
You could achieve this effect using a custom ViewModel that contains enough metadata to identify the object being edited/saved. You would use this in conjunction with a partial view that renders the ViewModel. The main page would use the metadata in the ViewModel to either direct the post to a specific controller action to save that particular object or pass the metadata back to a common action (as hidden inputs, perhaps) in order that that action can choose the proper table in which to persist the data.
Personally, I would not take this approach. My feeling is that the more general you make a view/action, the more work it becomes to adapt it for different circumstances. I have done similar things for viewing sets of objects, but for a detail view or editing I like to work with more specific models and views.

Resources