Liferay add categories to artical hook - liferay

i tried too automaticaly add some categories to an newly created artical via hook. but i don't know which action i should hook into. I tried hook in to the AssetEntry Model actions, But it's a failure. Can anyone help me ?

Categories are populated through asset_categories_selector taglib UI for assets. html/taglib/ui/asset_categories_selector/page.jsp is where categories gets populated.

You can override[using hook] JournalArticleLocalServiceImpl's addArticle method and add your logic to add categories to created JournalArticle OR you can have categories default selected by overriding jsp[categorization.jsp] .

Related

Autosave Feature in MVC

Can you please let me know how to implement auto save fetaure in asp.net mvc using jquery and ajax. I have a form as shown below
#using (Html.BeginForm(null, null, FormMethod.Post, new { name =
"frmStudentDetails", id = "frmStudentDetails" }))
{
}
The above forms having few controls like textbox, dropdown etc. Present logic is that as soon as the user clicks on save button it will go to the controller "Student" and trigger the action "UpdateStudent"
Is it possible to invoke the same controller and action automatically in a period of 1 minute. If so can you please let me know.
There are so many approaches to do this. The first one is you can make another Model for a Student-View like StudentViewModel. In which, you inherit the actual Model Class of Student and then add the extra field of searching, traversing, and updating the records that you are required. You must need to add script-tag-handlers to bind the data from your StudentViewModel.
For more dig in deep, you must read how the Dependency Injection and Repository Pattern works in MVC.

Kentico 9: Auto Add Binding in Custom Module

I have created a custom module (actually I have created a handful in recent years, and this same obstacle frustrates me every time) following the Kentico documentation:
https://docs.kentico.com/display/K9/Creating+custom+modules
The problem I end up with every time, is in developing the User Interface for Parent/Child classes. I create a Vertical Tab node, and beneath it I add an edit tab and a Binding tab for the child class. This all works, and I can add and remove bindings at will, but what I can't do is ADD a new child class and bind it.
Using the Standard Edit Binding template, I am able to bind EXISTING Job Titles to the selected Category, but I cannot CREATE a new one from that page:
To solve this, I created a custom Edit Binding template, and added a New Child Class Header Action that points to a New / Edit Object child:
Which gives me a button that I can use to add a new child class (Job Title):
This approach works per se, in that I can click the New Job Title button and create a new item on the subsequent page:
But no binding is created to link the child object (Job Title) to the selected parent object (Category), An even bigger problem is that once I click Save, I am presented with the following:
The new object DOES SAVE, but the post-save navigation is somehow failing. The event log offers little in the way of diagnostics:
So I thought to create a completely custom interface to accomplish my needs here, according to the Kentico documentation:
https://docs.kentico.com/display/K9/Manually+creating+the+interface+for+custom+modules
So I change the Element Content of the New Job Title page to a custom page that I created to post a DataForm for the new object:
Taking care to assign the proper Object Types on the Properties Tab:
The intent was to programmatically create the binding upon save and also handle the correct navigation to avoid the ambiguous parameter error above, but when this page loads, the UIContext.ObjectID and UIContext.ParentObjectID are both 0:
So I cannot create the binding programmatically. I was able however to solve the error that I received by manually assigning the redirect. The experience is still lacking even with this hack, since it returns to the listing page, but the user still has to click "Add Items" to assign the binding after successfully creating it with the custom page I built.
This cannot be the proper way to do this, so any help with getting me on the right track would be greatly appreciated.
In order for the EditedObject to have a value you have to either decorate the page with the EditedObjectAtribute e.g. like this:
[EditedObject("<custom.objecttype>", "<objectid>", ...)]
or set the object yourself:
int objectId = QueryHelper.GetInteger("objectid", 0);
EditedObject = SomeInfoProvider.GetSomeInfo(objectId);
In your case, I'd recommend exploring what query parameters are available on the page and using them to fetch appropriate object(s). Also, make sure "JobCategoryId" is passed to the "New Job Title" dialog so that you can create the binding.
Btw - kudos for well asked question!

Disable Create form on datatable with inline edit turn on

I intended to use datatable in GvNix on an entity where the create and delete are managed by some backend logic. Only allow View and Update on the entity using inline edit datatable. I managed to use the delete=false and create=false option in the table.tagx for the particular entity. But this only disable the create and delete icon. The create form is still there. Is there a ways to disable the create form above the datatable once the datatable has been created with inline edit?
It seems like there is an error on file table.tagx when validate create property.
I've fixed it with the following change:
Replace the line ~373 of file table.tagx from:
<c:if test="${inlineCreating}">
to:
<c:if test="${inlineCreating and create}">
I've applied these changes on commit: https://github.com/gvSIGAssociation/gvnix/commit/dd1ad58ab90998b3dcc5379fd98b8c484e61e76e
Please try it and tell me if it worked to you.
Hope this helps.
Regards.

How to update Layout in PortletLayoutListener

The goal is to implement a Tab Portlet - portlet for displaying and managing tabs containing nested portlets (similar to Nested Portlets Portlet).
One of the requirements is to remove the nested portlet references from Layout on Tab Portlet removal.
I implemented PortletLayoutListener and indeed, method onRemoveFromLayout is called on Tab Portlet removal. The listener updates the layout. While debugging the listener, I can verify that the changes were written to Liferay database (to LAYOUT table).
The Layout instance is obtained through LayoutLocalServiceUtil.getLayout(plid) method.
The update is performed with LayoutLocalServiceUtil.updateLayout method.
The problem is that the listener is called from UpdateLayoutAction, which afterwards updates the Layout itsef and overwrites my changes (it reverts them).
The question is - is it possible to update Layout in PortletLayoutListener.onRemoveFromLayout method? If not, is there other option I could use?
Hi the PortletLayoutListeners are intended to be used in relation to the portlet. So if you want to react on a change on the page in your portlet.
If you want to change the portal, I would have a look at the model listeners. Create a hook with a Layout model listener and try to make you changes in the afterUpdate method. But be careful not to affect the performance.
You may even require both of the classes one to make an indication and the second one to make a change.

How can I add extra properties to document metadata field types in Liferay 6.1?

I'm new to Liferay and I have the following situation:
I would like to add extra properties to document metadata field types in Liferay 6.1.20.
For example, I would like to add property 'readonly' to select boxes (see image), as it is a user requirement to show some controls disabled.
Should I use the Expando functionality, a jsp override hook or another approach?
I think Expando functionality, a jsp override hook are a good approach.But using Expando you cannot create it as mandatory field.

Resources