glori
I'm new here

Deprecated methods in interface: Link

Hello. I am using FirstSpirit 4.2.485.XXX

In the API of FirstSpirit is written, that the methodt Link.setAttribute(String atributeName, Object value) is deprecated.

An info is written "Deprecated. since 4.0 - use generic links instead - method will be removed with 5.0."

It's just only written that it is recommended to use the methods Link.getData() and Link.setData(Data data). And the form would be retrived viea Link.getTemplate().getGomProvider().

So, in my Java-File I am using following code until now and it is working. But for the future, I have to change it, and there is no really help.

My code:

LinkTemplate plainContentLinkTemplate = templateStore.getLinkTemplates().getTemplate("plain_content.standard");

Link link = plainContentLinkTemplate.createLink(masterLanguage);

link.setText(headline);

link.setAttribute(Link.CONTENT_SOURCE, "rezept")// setAttribute() is deprecated!

link.setAttribute(Link.CONTENTID , recipe.getId().toString())

Can anybody help me or tell a way how to change this for working with them in the next version of firstspirit?

Thanks and Regards.

4 Replies
Peter_Jodeleit
Crownpeak employee

You should use the method "getFormData()". On the retrieved FormData-instance you call "get(..)" and on the "FormField" instance you use the method "set(..)" to set your value. After this you store the changed FormData-instance in the link:

LinkTemplate plainContentLinkTemplate = templateStore.getLinkTemplates().getTemplate("plain_content.standard");

Link link = plainContentLinkTemplate.createLink(masterLanguage);

FormData formData = link.getFormData();

formData.get(null, "text").set(headline);

...

link.setFormData(formData);

Peter

Thanks a lot for your help.

It does work. I can create successfully the link and can save is to a DOMElement.

But,

Link.CONTENT_SOURCE and
Link.CONTENTID


are deprecated as well.

Do you maybe know what I have to use, to set the correct CONTENT_SOURCE and the correct CONTENTID for the link?

0 Kudos

This depends on the form element in your linktemplate. E.g. if it is a FS_DATASET you should use the corresponding API, i.e. DatasetContainer and the inner Factory class.

Peter
0 Kudos

Thank you very much for your help. I am using Link.

I've something for my problem.

This does work:

formData.get(null, "contentID").set(headline);

formData.get(null, "contentSource").set(headline);

It does really replace the deprecated method and field constants:


link.setAttribute(Link.CONTENT_SOURCE, "rezept");
link.setAttribute(Link.CONTENTID , recipe.getId().toString());

0 Kudos