What procedure does default form submit button handler follow? - drupal-6

I've set (and confirmed in the database) nodes under the content type miniapps to have the alias content/miniapps/9999/test (where 9999 is a node's actual id, and test is the node's title. Everything works fine when a new node is added - i.e. I get redirected to the proper page. However, when I edit that page and press Submit, I get the "page not found" error. If I manually enter the above path in the browser I go to the proper page. This happens even though every conceivable permission has been set, and in fact happens on my (the super admin) content. Any guidance or suggestions on why the wrong redirect appears to be assigned by the form submit button handler. Thank you very much.

Related

Navigation rules with xpage returning to another application does not work

I'm calling an xpage from a portal xpage and would like to return to the portal on success or cancel. I've set the next page(success or cancel) rule to Previous page. When I test with a simple cancel button it does not return to the previous page. In summary Application A opens a page in Application B in edit mode. When I click on a cancel button in Application B it does not return to Application A.
<xp:this.navigationRules>
<xp:navigationRule
outcome="xsp-success"
viewId="$$PreviousPage"></xp:navigationRule>
</xp:this.navigationRules>
I then tried with sessionScope variable with the return URL but the sessionScope variable does not seem to be available in Application B.
I must be missing something really basic. Can anyone give me a hand ? Thanks
Navigation rules apply only per application. "Special" rules like $$HomePage will always return to the application root, and $$PreviousPage will return to the last page stored in sessionScope. The last page in sessionScope is also application specific, that's why this is not working.
Try to open your application B with an URL parameter and store this parameter in the sessionScope of application B. Instead of using a navigation rule, you can simply do a redirect if a user cancels.

Chrome Extension Bind to Form Submit

I'm writing a chrome extension that needs to do some work when the user submits a form. I've got a content script running in the background that runs the following code:
$(document.body).on('submit', 'form', function () {
doWork();
});
That works perfectly on most sites, but breaks on the login form of twitter. Oddly, though, it doesn't break entirely. If I click the 'Sign In' button on twitter, the doWork() function will run. However, if I press enter to submit the form, doWork() never runs.
In my efforts to debug, I then copy and pasted my code into dev tools to rebind the function, and see if it worked. It did - even when using enter, the new binding worked.
My next thought was that maybe jQuery.on wasn't working on elements created via javascript (assuming the button submitted a hidden dynamically-created form via javascript, rather than the visible form, for some reason). So, I rebound the event like above, but added in a line that would alert me with the class name of the submitted form - all of the forms have unique class names on the twitter login page.
As you may have unfortunately guessed, clicking 'Sign In' vs. pressing enter alerted with the same class name - so, no matter which way I look at it, I have an event bound to that form submit, but for some crazy reason it is not getting called when I press enter.

Xpages partial refresh trigger full refresh

Trigger full refresh when logged out in 8.5.3. I don't care if the data is lost, I just want to trigger full refresh if partial refresh fails in case user is logged out or session has timed out.
I have two windows open. If I press the logout button on window 2, and then come back onto window 1 and try to do a partial refresh, it returns nothing (just blank value for that control). So how can I trigger a full refresh when the user is logged out?
I tried onComplete, onStart and onError client side events, but cannot figure out how I could find out when this logout has happened, I tried the following code:
var strUserName = '#{javascript: #Name("[CN]", #UserName());}';
alert("Start: " + strUserName);
It always returns the username rather than anonymous in window 1, even when user is logged out in window 2!
onError event never fires when partial refresh fails or returns blank value.
Any ideas or help would be greatly appreciated.
Did you try to lock the database down (Anonymous = NoAccess)? Then you should get an 404 and the error routine fires.
Update
You can:
add a redirect meta header to the page that kicks in when a session expires (cheapo solution, but might catch already most used cases)
Still lock down the database but give Anonymous the right "view public pages" and then have the page(s) that anonymous is allowed to see marked with the attribute "available for public access"
Make sure your partial refresh checks if nothing comes back and reloads the page then (most work since you need to alter business logic) - some sample of your code would be needed
onComplete has one weakness. The value bindings are evaluated when the page is rendered, not after a partial refresh, as you might think. This is due to the way the request works. When a request is sent, the callbacks for the request are bound (onStart,onComplete, etc.). Therefore the client side handler code has to be available before the refresh happens.
If the partial refresh doesn't refresh the item with the event handler(onComplete/onStart/onError), I think the value binding is only updated on page load.
There are several ways to solve this.
Have a client side function that does partial refresh on a hidden (by CSS) xp:text/etc. that shows the current user name. Fetch the content using theNodeReferenceVariable.innerHTML. If Anonymous is the current user:
document.location.href = document.location.href
You could also do document.location.reload(), but that might result in submits being resent.
Use the XPages Extension Library REST services. Same as above, if Anonymous, reload page.

Run a javascript function on click of popup icon of chrome extension

As chrome.browserAction.onClicked works only if there is no popup, is there any alternative method to fire a query when browser action icon is clicked?
Let me make myself clear..
I have more than one view i.e, html files in my extension. My default popup in index.html
Whenever I click on the icon I want to fetch some data from server. If I include this function in index.html or index.js, this function gets called every time I go to that page. Can anyone help me?
Thank you in advance.
What I would do is:
Have the behavior take place in the onload handler of the page. Since it sounds like the default popup page, index.html, can be loaded as time when the user is not creating the initial popup, I would create a page that is a dedicated initial popup load page that is not used anywhere else. This page could redirect to index.html or include it as an iframe.
Another option is to have index.html take a query string indicating how it is being used. Your initial popup could be index.html?init=1 and all other inclusions of the page simply use index.html. Then use window.location.search.substring(1) to test if a query string is present and take the appropriate action.
I'm also looking for an solution to this and I'm wondering if it is possible to start the browser action with no popup, detect the click, then set a popup with "setPopup()". If it works it doesn't seem like the nicest approach, I hope someone knows of a better solution.

Seam:token tag not being respected

When I click a command button, and then hit the browser back button to the form and click it again, it submits a second time without throwing the proper exception...
Even stranger, the form id itself is DIFFERENT when I come back, which implies it has regenerated a "valid" form id at some point.
Here's the relevant code: Any ideas?
<h:form id="accountActivationForm">
<s:token/>
<a4j:commandButton id="cancelActivateAccountButton"
action="#{controller[cancelAction]}"
image="/images/button-Cancel-gray.gif"
reRender="#{reRenderList}"
oncomplete="#{onCancelComplete}" />
 
<a4j:commandButton id="activateAccountButton"
action="#{controller[agreeAction]}"
image="/images/button-i-agree-continue.gif"
styleClass="activate-account-button"
reRender="#{reRenderList}"
oncomplete="#{onActivationComplete}"/>
</h:form>
Clarifications:
I inherited this, so I'm trying to change it as little as possible. (It's used in a couple places.)
Each action returns a view, not null. I have confirmed this by stepping through line-by-line.
The reRenderList is empty in my current test-case.
onActivationComplete is also empty.
I'm going to be going template-by-template to see if someone made it with nested forms, because my coworkers have had unrelated problems due to that, so it couldn't hurt to eliminate that as a possible problem.
The s:token is supposed to avoid double/multiple submits by impatiently clicking the submit button multiple times in the same request or by refreshing the non-redirected result in the webbrowser or by resubmitting the cached page in the browser history.
That it works when the client navigates back and forth by browser history just means that the pages with the forms are not cached in client's browser history and are requested as brand new from the server side again. That would indeed return a new token. Check it yourself with a HTTP tracker like the one in Firebug.

Resources