I'm working with Facebook Events via the Graph. The documentation is here:
https://developers.facebook.com/docs/reference/api/event/
I can access some of the fields such as id, name, start_time, and location without any trouble at all. But some of the fields are always undefined. Specifically, description is always undefined. However, the fields aren't undefined when I look at them via the Graph API Explorer.
This isn't just an isolated instance; it's happening all over my application. So I'm fairly certain that the error isn't typographical. The fields that are defined and undefined are always the same. For example, something as simple as the following returns accurate information across multiple events for each of the fields except description.
alert(facebookEventsArray[i].id);
alert(facebookEventsArray[i].name);
alert(facebookEventsArray[i].description);
Does anyone have any idea what the problem might be?
By default, you wont get the description of an event. You can explicitly mention the fields you require in your call. For eg:
EVENT_ID/events?fields=name,start_time,timezone,location,description
Related
I need to figure out what objects within a OpenUi5 JSONModel are bound to at least one UI component.
I want to check what objects are bound of the model and then get only new values of the bound objects from an embedded device. With other words I do not want to get all available information of a embedded device via web request if some of them are currently not visible / bound on the Ui.
Does anybody have an idea how I could figure this out using javascript.
I already saw that the JSONModel has a property called aBindings that lists all current UiBindings, but I wonder if this is the right way to get that information.
Thanks!
It looks like this is your first question here, so welcome to StackOverflow!
Although it is expected that you already try out the code for which you seem to have issues and then post it here with the errors or expected results, I will still try to help you out.
To get answers to your question, I would suggest you to read through the Data Binding section under Get Started: Setup and Tutorials of the SAPUI5 Demokit. This includes,
Creating a model
Property binding
Binding paths and formatting values
Once you get the basics right, you will see that with the concept of Two-way Binding, the model is already updated with the new values that you are looking for, if it's changed in the UI and vice-versa.
Also, if you are looking for a particular object or property, you can directly query the model instead of worrying about to which control it is binded.
For example this.getView().getModel("myModel").getProperty("/view/visible") will return the current value of the property "visible" regardless of which control it is binded to.
If my answer totally misses your question, please elaborate on your concerns and we can explore it further.
In Struts2 I have successfully implemented an updateErrorCount() method that updates a class member variable every time addActionError() is called through out various action classes. I can then access that variable with a property tag in the associated jsp. However, I am looking for a better solution.
Since the s:actionerror tag lists all of the errors added, is there a way to use an iterator tag or some other solution to display the error count along with all of the error messages right in the jsp?
I thought about overriding addActionError() to avoid having to call an additional method to keep an error count but if I could simply do it all in the jsp it seems much cleaner.
getActionErrors returns a collection, why can't you just call size on that?
I see few legitimate reasons to implement any of this functionality manually.
If you have specific needs you should enumerate them in your question, otherwise I don't see the point of doing this on your own.
I was trying to display a count of all online users on my website, and installed the meteor-user-status plugin to help with this. I thought all I had to do was add a template helper
Template.header.helpers({
numOnline: Meteor.users.find({"status.online":true}).count()
});
like so, and include the {{numOnline}} variable in my header template. But, for some reason, that resulted in always displaying 0 users online. However, when I simply ran the method Meteor.users.find({"status.online":true}).count() in the javascript console, it gave the correct amount of users online.
After messing around with it a bit, I got it to work by wrapping it in a function:
Template.header.helpers({
numOnline: function(){
return Meteor.users.find({"status.online":true}).count();
}
});
This change makes it work perfectly, but I have no clue why. Can someone explain why it was necessary to wrap it in a function?
Adding Christian Fritz, The only reason I think this can be happening is in the first case numOnline: Meteor.users.find({"status.online":true}).count() the collection is not ready at the point of evaluation of the template and assign 0 or empty array [] since is what the subscription return, and in the second case since is a function will react whenever a change occurs in a collection, so that's why will have the value a soon the collection get fill with the subscription and the function will get execute whit the most recent value.Just my two cents. Please correct me if I'm wrong.
Well, that's just what it is (and the documentation tells you so, too). The reason why this need to be a function is reactivity: in order to reevaluate the piece of code at a later point in time (when a reactive datasource has changed value), you need to have a function.
We have a campus map which has been created by a number of our students. For the most part, it runs fine, but there is one persistent error which we are unable to clear. There is a sidebar which lists out the buildings and points of interests which are represented on the map which, when clicked, [simulate a click][1] on the polygon for the building/poi.
function sideClick(poly) {
google.maps.event.trigger(buildingpoi[poly],'click');
};
Where buildingpoi[i] is an array which holds the information regarding each polygon.
Whenever a click is triggered, it refers to a method called shapeClick() which handles the display of information and repositioning of the map to center on the building/poi. Regardless of whether it is the polygon itself or the link in the sidebar, this method executes completely without error.
However, when the sideClick() function is used, or when the click trigger is called in the code, an error occurs in the Google API files, namely a main.js file:
TypeError: b is undefined
...(a.Va)||b.set("poly",null)})]};function VH(a){var b=a.Se;b.b||(Q(Xe,function(c){...
This error appears to occur after the successful execution of the shapeClick() method, suggesting that the error lies- as noted in the error message- in the GMaps API main.js file at some point after shapeClick() is called. Generally, this does not cause an issue on the front end, but when I attempted to include another method which calls sideClick(), any code I place after sideClick() is not executed due to the error.
I've attempted a number of my own tests/fixes, but the best I've been able to do is narrow down where the error is triggered. My searches also appear to come up with related yet dissimilar results. I assume the answer may be very simple, but for me it has been elusive.
Map: https://www.beloit.edu/maps/
Although you did not access the event-argument in shapeClick(what will not be supplied when you trigger the event), it seems that the API internally tries to access this argument.
The API tries to read the vertex-property(don't ask me why) of the PolyMouseEvent(that's what event is expected to be).
Accessing a property of an undefined object results in an error, that's what the message says.
Provide an empty object as argument when you trigger the event:
google.maps.event.trigger(buildingpoi[poly], 'click',{});
...and the error will go away(accessing an undefined property of an existing object is not an error)
Is buildingpoi[i] as you said an array holding information for the polygons? or a reference to the polygon itself?
This function needs the reference to the actual polygon, which is fine if it's in an array.
I needed to figure out how to get the value of a field on my form from within a handler function but I didn't know how to reference the field and kept getting errors. I spent time looking at the API, code examples and googling. Finally I found one example which works (I imagine there are others).
Assuming a form named MyForm and a field 'myField'
var myVal = myForm.getForm().findField("myField").getValue();
Maybe I'm just too new at this, but I don't think it's obvious from looking at the API docs.
So my question is, when you're trying to figure something out, what's your approach.
Thanks!
Assuming you have set the id of the field, you can use Ext.getCmp(id) to have the ComponentManager look it up. There's also Ext.getDom(id) which basically acts as a wrapper to getElementById.
In addition, many event handler functions allow setting the scope of the function itself. The documentation for that event should note which object is setting the scope. You may be able to set the form field as the scope object and use this.getValue() but it's hard to say without knowing exactly what you're trying to do.
To answer the question at hand: the more you code, the more you grok. Ext JS has a bit of a learning curve but the example source code provided in the download is a great place to start. There are several errors and omissions in the documentation though, so the most authoritative place to go for answers is straight into the source. Reading up on JavaScript callbacks doesn't hurt either.