Action in fb:request form is always null - java

UPDATE: this has just started happening again, would appreciate any help.
I am using server fbml to render an Invite Friends iframe and it was working fine up until two days ago. Basically, after submitting the form, a java action should be invoked where I get all the id's of the user's invited.
However, I now notice that an "invite by email" popup is showing up and, most importantly, my java action isn't being hit at all. When I inspect the form in firebug, I notice that the action is always empty (though all other parameters are preserved correctly).
I've tried setting email_invite=false on the multi-friend-selctor but to no avail.
My code looks like the following:
<fb:fbml>
<fb:request-form action="http://localhost:8080/myAction.do?method=someAction" method="POST" invite="false" target="_top" type="invite" content="CONTENT_GOES_HERE" >
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use our app." target="_top" email_invite="false">
</fb:request-form>
</fb:fbml>
</script>
Any help would be greatly appreciated on this.
UPDATE: this has just started happening again, would appreciate any help.
Thanks, gearoid.

Facebook have recently added an extra step into the multi-friend selector process, which is what you're seeing. There isn't, as far as I know, any way to stop this from appearing.
However, you should still be getting the result of the selector sent to you once the user navigates away from the "invite by email" popup.
Facebook's latest update can be seen in this status post.

To prevent that popup appearing add this attribute to the multi friend selector
import_external_friends="false"

Turns out this can happen a lot of different ways.
A) You can call FB.init multiple times
B) Call FB.init with the wrong key
C) You can supply a action that doesn't map to your current application on facebook
D) You or your staff can accidentially supply the same canvas/app url for two apps.
Most of of the solutions online point at A-C. When someone accidentally creates a second dev app pointing at localhost or 127.0.0.1 as the canvas url for multiple apps you admin you will get hosed. Took me hours upon hours to think to search our other apps. So i hope this saves someone a truck load of time. Cheers

I had an incorrect appId set in the fb-root javascript. This caused the error.

Related

Strange behaviour with Navigate().back()

I'm facing an issue about the back function in selenium.
When I call it, it does nothing but if I call it twice, it works perfectly.
I've tried manually on my web browser and one back button is enought to go back.
Someone know why?
Thanks in advance!
The behavior might be a result of a scripted page with some code for auto-refreshing, suppressing or overriding the back button event /action.
So you might:
debug the page and stop on any JavaScript execution
and ask for a correction/change if you are in control of the page
avoid the back-button-action from Selenium-framework, that simulates browser back navigation
use instead a given button (if available)
implement this "feature" in your own framework as a workaround to click it (always) twice to ensure successful back-navigation

Browser turning a post request into a get

I have a java webapp using the Tapestry5 framework where I'm seeing exceptions in my logs that look something like this,
Forms require that the request method be POST and that the t:formdata
query parameter have values
When I spoke to the user group, it was believed that there is some sort of issue where the browser is turning a form post into a get request. I've been seeing this happen with legacy versions of ie and modern android devices using later versions of chrome.
My question is what would cause this type of behavior?
Edit:
Example form
<form id="sortForm" method="post" action="/product/index.sortform" data-validate="submit">
I'd also like to rule out bot activity do to the fact I see this happening on some of my apps that sit behind firewalls without any bot access.
The problem caused by address bar completion of all browsers and the solution is that, please add autocomplete="false" to all of your forms.
Edit 1:
If you do not use action type, it works like "GET" method. Be sure that you added the action "method" attribute value of the form as "POST".
Edit 2:
Please check GET submits instead of POST ones. Tapestry
There was a major error emphasized at that link (jira) https://issues.apache.org/jira/browse/TAP5-2066 which is solved before.

Push data from Servlet to webpage

Ok .. I think this question is dumb but its something I need so asking.
I have a servlet that checks health status of about 20-50 servers depending on situations.
I am trying to reduce the time to as low as possible but it still takes me 15-20 seconds to respond.
I am printing stuff on console for my satisfaction that the servlet isnt stuch but a user cant see that.
Is there any way I could print data on the requesting or a new page so that user knows that server isnt stuck - I dont wanna pass the request as there is still some processing to do.
I just want to print like I do in console. I checked System.setOut(PrintStream) but this also caries the data only after I pass request dispatcher - not good for me.
I am sorry if its a dumb question. I couldn't find a solution for my problem. Any help will be appreciated. Thanks in advance.
UPDATE: I am currently displaying a picture that says loading. But even if the server crashes the picture is still there. In my case its not true indication of servers state.
I think what you are looking for is supported by WebSockets, https://www.google.com/search?q=websockets.
You'll have to update your javascript, assuming your browser supports it, and then update your servlet code, and container to support. Jetty supports it, I'm not sure about the other containers.
Or alternatively, you could save your progress to a table or something and poll that data.
With the first request you could show a page with some kind of "please wait" indicator and do a second request that actually fetches the data (eg. via JavaScript).
Show a loading bar using javascript . This would tell the user that something is happening in the background .

why a:commandLink's action attribute works but h:commandLink's does not?

I had a very simple task today that I needed help with. First let me explain my environment.
We are on a Java/Hibernate/SEAM/Facelets/JSF/RichFaces & A4J setup.. and I don't know to much about it.
I work with it when all of the work on the old asp platform is complete.
SO I had something like this (I just cannot remember if I had () after stockCheck.. I am home now):
<h:commandLink value="Submit" action="session.stockCheck()"/>
The stockCheck() method would NOT run though! It does not return a value it's job is to create a record in a DB, and it does that perfectly.
So I tried a few things and nothing would work, I asked my co-worker and he said to just change it to a4j and it should work. I asked him why, but he did not know.
See now I get REALLY hung up when I do not understand WHY things are or are not working.
The solution to submit the email to the database was:
<a:commandLink value="Submit" action="session.stockCheck()"/>
BTW: we have our namespace for a4j set to just a.
I am here hoping somebody can explain some things about this to me.
What went on behind the scenes and what needs to be understood about the failure of <h:commandLink> in this situation?
Thank you.
That can happen if you're nesting forms. This is illegal in HTML and the behaviour is unspecified and dependent on the webbrowser used. The ajax link doesn't submit the form, it just collects the input values by JavaScript and then sends a XMLHttpRequest in the background.
See also:
commandButton/commandLink/ajax action/listener method not invoked or input value not updated

Hibernate Exception Fixed By Alt+Tab

I've got a very curious problem in Hibernate that I would like some opinions on. In my code if I do the following:
Go to page A
Click a link on page A to be taken to page B
Click on data item on page B
Exception thrown
I get an error telling me:
failed to lazily initialize a collection of role: XYZ, no session or session was closed
Fair enough. But when I do the same thing but add an alt+tab in the middle, everything is fine. E.g.
Go to page A
Click a link on page A to be taken to page B
Hit ALt+Tab to switch to another application
Hit ALt+Tab to switch back to the web browser
Click on data item on page B
Everything is fine.
I'm a little confused as to how switching focus from my application makes it act as I want it to. Does anyone have any light to shine on the subject? I don't think it's a locking issue as even if I do the second set of steps quicker than the first, still no error.
It's a Seam application using Hibernate 3.3.2.GA & 3.4.0.GA.
It's not really related to switching the applications; maybe your browser updates something during focus lost/gained.
The reason for your issue is this:
In the first request, you load an object and store that in the session. This object contains a collection of some kind.
In the next request, you try to do something with the collection but you forgot to call session.refresh(object), first.
What happens is that the session is automatically closed when the first request is finished. But the backed collection in your object still contains a reference to it (so that it can be loaded automatically when you access it for the first time).
are you using javascript? Maybe an event is firing when you switch back to the browser that somehow clears the bad state?
Does your page complete it's rendering? I have found that sometimes when I get errors, instead of displaying the error, the server simply quits producing output. It outputs the error to the log, but thats about it. I end up with a half completed page. View source and see if you get to the end of the body, perhaps your switching caused the server to get lazy, or your browser to terminate the connection prematurely when the error occured
My advice is to do a unit test to see if you can reproduce the error in other environment isolated from the browser ;)

Categories