Programmatic login into jsf application - forms

I found examples of programmatic login into jsf based application, like this from Balusc.
Maybe it is silly question but, when I use form based authentication, I can use only a simple html form with
<input id="username" type="text" name="j_username" />
<input id="password" type="password" name="j_password"/>
in <form method="post" action="j_security_check"> form.
I cannot use jsf form from example, why?

Because it's not JSF who handles the login, it's the container itself. The JSF <h:form> does not allow you to specify a specific action URL. So you have to use <form>.
But your question title is confusing. Using a j_security_check form is not "programmatic login". It's "container managed login". The real programmatic login way is calling HttpServletRequest#login() yourself. You can do this in a JSF managed bean action method which is invoked by a JSF <h:form>.

Related

PHP 5.3.10 global behaviour

I'm having trouble with a global variable, I think it might be pulling its data from a HTML Form Input, but I can't find any documentation on the web about global var pulling data from a HTML Form Input.
Thanks.
When a form is submitted the method tag specifies if it is a POST or GET request. Depending on what method your form is using your form values can either be in your $_POST or $_GET Super global.
Example:
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
After the submit button on the form is clicked the form contents can be found by referencing the name attribute in the super global(In this case the POST).
$_POST['name']
$_POST['email']
For documentation see
http://php.net/manual/en/reserved.variables.post.php
This applies to PHP 4 >= 4.1.0, PHP 5, PHP 7 ie. fits PHP 5.3.

Sinatra creating a delete http request using name="_method". What is going on?

I read this:
http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark
and I still have the question of how this html form is working behind the scenes.
<form action='/<%= idea.id %>' method='POST'>
<input type="hidden" name="_method" value="DELETE">
<input type='submit' value="delete"/>
</form>
Is Sinatra looking specifically at the <input> name field and does that _method mean something internally to Sinatra and Rails? If so, what is going on behind the scenes?
Yes - as documented in the Sinatra Readme :
Use _method magic to allow put/delete forms in browsers that don't support it.
The "magic" is actually implemented in the Rack middleware, see the code in 'lib/rack/methodoverride.rb'

post form to an iframe on another form (is it possible)

I'm using ASP.NET web forms and i need to post data to an iframe, the problem is that in web forms I have the main form tag(form1), so i need another form tag(form2), to post data to the iframe that is in the main form1.
Basically i have this:
<form method="post" id="form2" action="http://localhost:58903/WebForm1.aspx" target="webApp">
<input type="hidden" name="ValidationUserName" value="david" />
<input type="hidden" name="ValidationTokenId" value="13123132132" />
<button type="submit">Send info to inner iframe</button>
</form>
<form id="form1" runat="server">
<iframe id="webApp" name="webApp" src="http://localhost:58903/WebForm1.aspx" style="width: 800px; height: 800px;"></iframe>
</form>
With this approach in open a new tab, if i put the iframe outside it works ok, but if i do this the layout is changed and i don't want this.
Is this possible?
If all the forms are in the same domain you should not work with iframes.
What exactly are you trying to get here? didn't realize completely
Done it, it was missing the "name" attribute in the <form> tags.

can you append form data to a URL in a phonegap webapp?

In my phonegap webapp, I have a form with some serious GET action on it. When I click submit, I want to open a new page and extract the form data from the URL with javascript.
Question: can you do that in a phonegap app, when you're not actually in a browser?
Yes, you can! It's as simple as I said:
<form action="destinationpage.html" action="GET>
Input your data:<input type="text" name="data /> <br />
<input type="submit" value ="Continue">
</form>
Then see the answer to this question for retrieving your data on the next page!

POST request in GWT

i first tried to make request to server with GET method and it works fine. my request would process a file then return as a pdf file and would open on a new browser. what i did is overriding the doGet() method. since having a GET request is only limited to few parameters, i must change it to doPost() mehod but the problem is that it can't be overrided because the method is final.
in an HTML FORM, what i wanted to happen is something like this:
<form method="post" action="http://differentdomain.com/appserv/appserv.php">
<input type="hidden" name="fwi_script" value="app/custom/cusapp/interface" />
<input type="hidden" name="trx" value="<trx>
<productid>PROD1</productid>
....../** transaction details here */
</trx>" />
<input type="hidden" name="fcompanyid" value="SHOST101" />
<input type="hidden" name="fwi_action" value="PRINT_PENDING_SALES" />
<input type="hidden" name="fexcel" value="0" />
<input type="submit" value="Submit" />
</form>
this html form will print the order slip of every transaction when user clicks on the post order button.
anyone can give an idea on how to POST request in GWT server? i think i can't do it with RequestBuilder since i will be having the SOP problem since i will be connecting to a different domain.
To build very nearly the same html you have in your question, start with a FormPanel and add the form fields you need to it. Make sure to configure the FormPanel with the correct action and method, and to provide names (and possibly values) to the fields added to it. To fire off the request, submit() can be called.
The solution is to make a normal GWT RPC call to your server and have the server make the POST request to the server located on a different domain.