im reading nfc tags through my created hook and I would like to pass them to my data properties.
It shows me that I cannot read or set the property 'currentArticle'. I tried suggestions like
let self = this
self.currentArticle
but it did not work. Some people say you should have access to data variables like:
this.currentArticle
That way doesn't work as well. Any suggestions?
I solved it through declaring let self = this at the beginning of the created hook.
Then I simply used the self.currentArticle as I already talked about the suggestions I have seen about this problem.
Related
I would like to do some interesting stuff with the hits that are being displayed based on the search query that user is not only typing into search box but actually filtering using the instant search filters. I have filter based on hierarchical events_location taxonomy. Based on what user selected I would get the info in JS variable that I can then further use to do other operations in the hits div, specifically on each hit card.
So my URL when searching updates like this:
/what-to-see/?q=&idx=sdbeta_posts_events&p=0&hFR%5Btaxonomies_hierarchical.events_calendar.lvl0%5D%5B0%5D=JUL%204&hFR%5Btaxonomies_hierarchical.events_category.lvl0%5D%5B0%5D=All&hFR%5Btaxonomies_hierarchical.events_locations.lvl0%5D%5B0%5D=Paddock%20Stage
I could potentially take the URL and extract the data from it, but I am sure there is more elegant way of working with the query.
In InstantSearch.js, the state is managed by another library called the algoliasearch-helper. Through this library you can read and write the search parameters.
The cleanest to access the helper is to build a custom widget, which is a plain object with lifecycle hooks (initial rendering and the other renderings). You can read more about custom widgets there.
Once you've accessed the helper, you can read and write with the helper API.
This can be found under search.searchParameters
So:
console.log(search.searchParameters);
Will give you whole object that you can then work with.
There is however one issue with this and that is that it works only on initial load. I was unable to make this work or get any data after starting to selecting categories. So if anyone knows how to use this so it updates after each selection please comment bellow.
I would like to set a marker interface to some objects that should have additional fields. If I remove this marker interface again the fields should be removed too.
Now I'm trying to understand plone.behavior. But I'm not sure if a behavior must be enabled for all objects of a type or is it possible to enable it for only a subset of objects of that type?
Take a look at collective.instancebehavior, an add-on aimed to do exactly what you want: to enable behaviors per content type instance.
Unfortunately I don't think there is a solution out of the box.
The simplest thing you can do is working on the form fields by overriding the updateFields method in the form.
This is untested demo code:
def updateFields(self):
if not IMyInterface.providedBy(self.context):
self.fields = (
self.fields.omit('IMyBehaviour.my_field')
)
As a reference have a look to:
https://github.com/plone/plone.app.users/search?utf8=%E2%9C%93&q=def+updateFields
I have custom content type, which has target association. I want to set up a policy, which perform some action, when association is removed. I wrote this policy as I usualy write another policies, but in some reason it does not work. My init() in OnDeleteAssociationPolicy implementation looks like this:
policyComponent.bindClassBehaviour(
QNAME,
PublishModel.pubWebContent,
new JavaBehaviour(this, QNAME.toPrefixString(), NotificationFrequency.EVERY_EVENT)
);
PublishModel.pubWebContent is qname of my custom content type. Now I think when onDeleteAssociation() is called, I should check which association was deleted. But this method is never called after remove association :(. How to set this policy? Should I provide PublishModel.pubMyAssociation instead of PublishModel.pubWebContent (that does not work too)?
I googled a little bit and found working piece of code, which helped me to get that policy worked. The point is to use bindAssociationBehavior instead of bindClassBehavior method. So working binging should look like this:
policyComponent.bindAssociationBehaviour(
QNAME,
PublishModel.pubWebContent,
PublishModel.pubGroupAssociation,
onDeleteAssociation
);
I'm currently working on a GWT project. The thing is, I find very hard to believe that I need to repeat some boilerplate over and over to bind the data from an EntityProxy (say a getSomeData() method) to a UI component (say a TextBox).
How do you guys overcome this issue? For now I have to create a method to read from the TextBox and set it to the EntityProxy, and a method to write to the TextBox after reading from the EntityProxy.
Basically, it's always the same! i.e.:
// Update the text box
T someData = entity.getSomeData();
textBox.setText(someData);
// Update the entity
String value = textBox.getText();
entity.setSomeData(value);
You get my point? I'm aware there is no Reflection at client side. I could use deffered binding but I'm not sure how or if it is a good approach with RequestFactory's EntityProxys.
Thank you
I use the technique you have defined in your question to push and collect data from my controls. Recently I have found out that there is a built-in feature of GWT called Editors. I didn't have a chance to try it myself yet but perhaps you want to check it out it seems promising. Also here is another useful link from Thomas Broyer's blog about Editors
I'm trying to bind a TableViewer to a
models = List<ModelObject>
, but I don't really get the hang of it. The binding should be possible via master-detail and a databinding context (DataBindingContext), so that I'm able to write the changes of the list (and its elements) to the model only on request (dbc being set to POLICY_ON_REQUEST), i.e. in a saving action of an editor.
With simple Text fields this works like a charm, but I can't find any similar example for TableViewers.
When I look at the API for instance of ViewerSupport, then I can only bind it, but without the option of giving a DBC or a master-detail. This works:
ViewerSupport.bind(aViewer, new WritableList(models, ModelObject.class), BeanProperties.value(ModelObject.class, "name")));
But as stated it doesn't allow to use a dbc nor a master-detail.
Is there a solution to that, or does TableViewer just not support databinding as I intend to use it?
Is there a workaround or some API i missed?
Thx for the answers in advance!
Now that I looked a bit further I figured out how to use master-detail:
tmp = BeansObservables.observeDetailList(masterObservable,
"name", ModelObject.class)
ViewerSupport.bind(aViewer, tmp, BeanProperties.value(ModelObject.class, "name")));
The question remains, how to make the changes in the list and the list elements not directly persisting (that is POLICY_ON_REQUEST), so that I can save them on user request. More specifically: How do I inject a DataBindingContext somewhere...