Liferay Template for DDL - liferay-6

Under Site-Administration->Content->Dynamic Data Lists-> Manage Data Definition->Manage Templates I like to create a new Freemaker template. In this template I like to call the class GetterUtil:
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")>
<#assign GetterUtil = serviceLocator.findService("com.liferay.portal.kernel.util.GetterUtil")>
If I do so I get the following error:
serviceLocator.findService("com.liferay.portal.kernel.util.GetterUtil")
is undefined.
It cannot be assigned to GetterUtil
At the end I want to call
long formDDMTemplateId = GetterUtil.getLong((String)row.getParameter("formDDMTemplateId"));
in my DDL Template. This line comes from dynamic_data_lists/record_action.jsp.
Is the object row equal to the object cur_record from this post?

GetterUtil is not Liferay Service, it's just an util class. Inside DDL template it is bound as a getterUtil variable, eg: getterUtil.getString("asdf").

Related

AEM6.5 Passing paramater to the resource from HTL/Sightly template

I have a component that uses two different resources in its HTL/Sightly template.
Is there a way to pass a parameter, to the say in my example the eventResource template, so that I can depending on this passed paramter change a css class on it?
<ul data-sly-list.teasers="${model.resourceList}" class="teaser-list-alternating c-list--reset">
<sly data-sly-test="${teasers.eventTeaser}"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser'}"></sly>
<li data-sly-test="${teasers.contentTeaser}" class="l-stack l-stack--horse"
data-component-hook-content-hub="teaser"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/contentHubTeaser'}"></li>
</ul>
I tried using data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='blabla'} to no availability.
#RequestAttribute(name = "contentHub")
private String contentHub;
The requestAttribute contentHub in the eventTeaser model is alway null and I am not sure how to get the selectors value in the eventTeaser template.
I can do it using TypeScript on the front end part but it is not very clean.
I was able to solve it using the selectors indeed and reading the selector value directly from the other sightly template. Here is the documentation I refered to:
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='inContentHub'}
 In the eventTeaser template I then used the following:
data-sly-set.inContentHub="${'inContentHub' == request.requestPathInfo.selectorString}
and depending on the value of the inContentHub variable I was able to change the css class which was my ultimate goal.

Copy data from cObject in typoscript

I would like to copy the values from a cObject data attribute in typoscript:
<f:cObject typoscriptObjectPath="lib.datei" data="{link}" />
in ts I can get it with:
lib.datei = TEXT
lib.datei.current = 1
it works, but I can not copy or reference it to another ts-object:
lib.test = TEXT
lib.test < lib.datei
if the value of lib.datei is a plain Text it works...
where am I wrong...??
I think you missed the context. the Context a typoscript object is valid and has a specific value.
if you call some typoscript rom a fluid viewhelper that specific object has a value. Inside that object you also can access global values.
But you have no access from another (temporarily) object called in another fluid-viewhelper call.
Neither can you access in your page rendering process on that specific value as that object has no input in that context.

TYPO3 FAL : add and read a custom field in a fluid template

In my custom extension I introduced a binary variable to the image metadata that needs to be read, similar to the "Show in list view" of tx_news.
With tx_news as example I was able to add the variable, the new palette shows the checkbox in the backend and the selection is registered in a new database field in the sys_file_reference table ...
I first tried to declare it in the domain which did work but I could not use the variable since it was an array of the same files in which I tried to use it, calling it within a loop broke the loop ... (this was my question)
now I need to use this new variable in my fluid template, if I loop trough the items the new variable named opentab is visible if I debug like this:
<f:for each="{object.items}" as="item" iteration="iteration">
<f:debug>{item.originalResource}</f:debug>
# debug result
TYPO3\CMS\Core\Resource\FileReferenceprototypeobject
propertiesOfFileReference => array(36 items)
uidOfFileReference => NULL
name => NULL
originalFile => TYPO3\CMS\Core\Resource\Fileprototypeobject
mergedProperties => array(empty)
propertiesOfFileReference has "title" which I can use like this {item.originalResource.title}
in propertiesOfFileReference I see "opentab" with its correct value but I found no way to use it !!!
Use {item.originalResource.properties.opentab}

How can I pull data in a controller and form for one model that is in a different model with out a foreign key relationship?

I am new to rails and haven't really done to much with data outside of the model.
I have a form that references a table controller for files. I want to add an dropdown that will display a list of projects from a project table for the user to assign a the file to a project if they want too. Assigning a project is not a requirement. The file can be unassigned to a project. I do have a project_id column in the file table for those projects assigned but it is allowed to be null and I did not build a relationship because I need to have cases where there are none.
Can someone please tell me how to do this?
When they evaluate the file, the screen posts back with a save or update button depending if it has already been saved in the database.
At the same time as the save and update pop up on the right I want to display a list box of the projects with an assign project button. If new just a list, if update either just a list because not assigned or display the selected value in the list if already assigned, while allowing them to change it from the list if desired.
In the file controller method that posts back to the UI I have this code:
#file_alias_filedata = FileAliasFiledata.all
#projects = Project.all
for update
#projects = Project.find(params[:id])
In the form I have this code:
<p> <label> Select Project to Assign:</label> <br />
<%= select_tag 'projects', (#projects.present? ? options_for_select(#projects, #selected_project) : []) %> </p>
The form runs but I get this in the dropdown box:
#<Project:0x))7ff531ab4518>
Can someone please help me figure out how to accomplish my task and why I see the strange box value?
What am I doing wrong?
Thank you for your help!
Assigning a project is not a requirement. The file can be unassigned
to a project. I do have a project_id column in the file table for
those projects assigned but it is allowed to be null
From the docs:
belongs_to(name, scope = nil, options = {}) public
Specifies a
one-to-one association with another class. This method should only be
used if this class contains the foreign key. If the other class
contains the foreign key, then you should use has_one instead. See
also ActiveRecord::Associations::ClassMethods’s overview on when to
use has_one and when to use belongs_to.
Methods will be added for retrieval and query for a single associated
object, for which this object holds an id:
association(force_reload = false)
Returns the associated object. nil is returned if none is found.
Likewise,
has_many(name, scope = nil, options = {}, &extension) public
Specifies
a one-to-many association. The following methods for retrieval and
query of collections of associated objects will be added:
collection(force_reload = false) Returns an array of all the
associated objects. An empty array is returned if none are found.
But belongs_to() and has_many() are supposed to make things more convenient for you. You certainly do not have to use them.
Next,
and why I see the strange box value? What am I doing wrong?
You see the strange value for the same reason the following two loops display different things:
class Dog
attr_reader :name
def initialize(name)
#name = name
end
end
#dogs = [
Dog.new("Sam"),
Dog.new("Betty"),
Dog.new("Pete"),
]
#dogs.each {|dog| puts dog}
#dog_names = #dogs.map {|dog| dog.name }
#dog_names.each {|dog_name| puts dog_name}
--output:--
#<Dog:0x0000010099a308>
#<Dog:0x0000010099a2b8>
#<Dog:0x0000010099a268>
Sam
Betty
Pete
You will see the same result if you do something like the following in a view:
<div>
<%= select_tag "dog", options_for_select(#dogs) %>
</div>
<div>
<%= select_tag "dog_name", options_for_select(#dog_names) %>
</div>
If you read the docs here:
http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_for_select
...you will see several examples, which should make it clear that options_for_select() takes an argument that is:
An array of Strings.
A Hash where both the keys and values are Strings.
An enumerable that iterates over some Strings.
etc.
Do you see a pattern? It's Strings! options_for_select() needs an argument that consists of Strings. If the argument is not a collection of Strings, e.g. an array of project objects, then options_for_select() tries to convert the objects to strings by calling to_s() on the objects. And the default to_s() method is Object#to_s() which is inherited by all objects and produces a string containing the class name and the object_id.
I am also new to rails, but I think you can try using the options_from_collection_for_select method.
<%= select_tag :search_state, options_from_collection_for_select(State.find(:all, :select => :name), :name, :name) %>
Hope this help. Cause it certainly helped me.

Datasource + .NET controls

I am using OpenEdge 10.2B and OpenEdge Architect and I did the following steps:
created a form.
added a .NET grid control and a button that I named gridCustomer and btnProcess.
created a temp table like this:
DEFINE TEMP-TABLE ttCustomer
FIELD CustNo AS CHARACTER
FIELD Name AS CHARACTER
FIELD City AS CHARACTER.
added an event ButtonClick event.
In this event, I am able to populate the temp-table but I could not assign it as a datasource like this:
ASSIGN gridCustomer:DataSource = THIS-OBJECT:ttCustomer.
I get the error message : could not locate element ttCustomer in class.
Is there an example or a documentation somewhere about how to populate a datasource of a .NET control?
Thank you very much!
Sebastien
You have to assign a BindingSource object that points to a buffer, query or prodataset handle:
gridCustomer:DataSource = new Progress.Data.BindingSource(BUFFER ttCustomer:HANDLE).
Look for Progress.Data.BindingSource class in the OpenEdge Help for a detailed explanation.