Joomla simple text area that send data via POST - joomla2.5

I'm developing my Joomla! 2.5 Component.
It, with an username && password passed via admin area, could connect to a webserver that send info via XML.
I can show this component in any part of front-end without problem.
Now i need to insert, in frontend for end-user, a single text-area where users could insert a value (e.g., theyr card number [it's a loyalty component]) and this value must be passed to previous component.
ATM I don't need AJAX call, page could be refreshed.
So process it must textarea => insert data => press submit => show component with result (page refresh, no problem).
I need to develop a plugin? I need to "extend" component? Saw several topic on web but i didn't found any that show a (i think) simple case like my.
I need a hand from you, to be on correct way.
Thank you.

In your main controller file you can access the post & get values, so
Where you want to place the input: Just create a form that points to your component, with appropriate
<form action="index.php?option=com_yourcomp" method="get"
<input type="text" name="your_text_input"...
Add all extra fields that you need.
In the controller.php of the com_yourcomp you will be able to access the user data with
JRequest::getVar('your_text_input') or jInput as you prefer.
Note on method="get": you do so if you want your users to be able to bookmark the page or you plan a redirect in your component. The user inputs must be limited to a few thousand chars at most. Otherwise use post, it really depends on your needs.

Related

How to store a returned javascript value in a django form?

I want to store things like Browser type and GPS locations for mobile devices along with user input data.
I know how to set up a form in Django so that the user inputs are stored in the database. But how would I go about executing a Javascript function that will a return a value to be stored in the same model as all the user inputtext in the form?
I found reasonable two ways:
I would go for api and do request to server with information you want to store and put it to your model (for instance REST django-rest-framework). But its more complicated since you need to handle authorisation.
As altenative to api you could create hidden fields in form which would be filled by js code executed from the browser. When user clicks submit button he sends you data with no need to manually provide it.

Is QtWebkit needed to fetch data from websites that need login?

As the title implies,
I need to fetch data from certain website which need logins to use.
The login procedure might need cookies, or sessions.
Do I need QtWebkit, or can I get away with just QNetworkAccessManager?
I have no experience at both, and will start learning as I go.
So please save me a bit of time of comparing both ^^
Thank you in advance,
Evan
Edit: Having read some related answers,
I'll add some clarifications:
The website in concern does not have an API. So I will need to scrape web elements for the data myself.
Can I do that with just QNetworkAccessManager?
No, in most cases you don't need a full simulated web browser. In most cases, just performing the same web requests like a web browser would do is enough.
Try to record the web requests in your browser, using a plugin like "HTTP Live Headers" or "Firebug" in Firefox. I think Chrome provides a similar tool out of the box. These tools record the GET and POST requests done by the website when you send a form in the webpage.
Another option is to inspect the HTML code of the login page. Find the <form> tag and its fields. Put them together in a GET / POST request in your application to simulate the same form.
Remember that some pages use randomized "tokens" in their forms, some set the tokens as cookies. In such cases, you need to request the login page itself in your application first (before sending the filled in form). Both QWebView and QNetworkAccessManager have cookie support.
To sum things up, I think QWebView provides a far more elegant way to simulate user interaction with a web page. The manual way is, however, more "lightweight", as you don't need Webkit and your application might be faster (because only the HTML page is loaded, without any linked resources like images, CSS, javascript files).
QWebView as class name states is a view, so it views something (in this case web pages). If you don't need to display loaded page, then you don't need a view. QNetworkAccessManager may do the work, but you need some knowledge about HTTP protocol, and also anything about target site: how does it hande logins, what type of request you have to send to login etc.

Process a query without changing the page

We have a page which is dynamically generated after a few queries in the database. There are some links that when they are clicked by the user, update some information on the database but they change nothing on the webpage (or the display a discrete message).
How could we stay on the same page without re-rendering it?
Ideally, the corresponding view.py would process the queries and update the database but not the webpage.
You can send and receive your own XMLHttpRequest, but it is too much of works to do and IE will create a lot of problems.
Have you ever heard about jQuery? I strongly recommend you take a look at it and learn how to send and receive Ajax request using it.
You need to make an AJAX call back to the server with the user's actions, and process it on the server. You probably want a different view to process the AJAX request -- you could do it with the same view, but it would be somewhat silly to. The response from that view contains data (probably as JSON) or HTML, which you display on the page with javascript. Check out jquery -- it's great for the client side.
You could accomplish this with plain Javascript and AJAX. When the user clicks on a link, use XMLHttpRequest to call view.py to process the queries.
eg. For the link: <a href="#" onclick=submitdb(); >Click me!</a>
For a tutorial on implementing AJAX (XMLHttpRequest) with Javascript, have a look here:
http://www.quirksmode.org/js/xmlhttp.html

Sitecore (Web Forms for Marketers) success page

Let's imagine I've made a simple form using the Web Forms for Marketers module 2.2 (for CMS 6.4), and have set this up to use a 'success page' (server side redirect to a specified sitecore item). This works great.
Now it turns out that the thank you page needs to show certain field variables from the form which was just submitted.
"Dear x, thank you for your interest in Y".
On the success page, it seems like there is no way to retrieve the information (server-side) I need to show this information.
What would be a good way to approach this problem?
Is there a way to hook into sitecore webforms before the page is redirected to the success page (so I can pass along an orderId, for example)?
You can create a custom action which will give you access to all the forms data. From the action you can redirect the user to the appropriate place. You can find documentation on how to create a custom action in the reference guide on page 42.
Make sure your action is always after Save To Database because otherwise the data won't be saved.

Smarter sharePoint Forms. Redirect to another list based on entry on the first list?

On Moss 2007.
Without completely ripping apart the native SharePoint generated list newform. Is there any way to redirect users to another list's newform based on what they enter in the current list newform?
Maybe, can the source redirect point to a form that interpreting fields passed in a query string and then decide where to take the user?
By chance is this any more possible in SP 2010?
One approach would be to create a new 'NewForm' that inherits from the standard NewForm and add the redirect logic to the page after the form has been submitted. This thread looks like it can get you started on how to override the page.
Another approach may be a custom web part that checks the status of the list and performs the redirect. Maybe you can do something with Javascript and the content editor web part.
Event receivers will not work, as they happen asynchronously and have no sharepoint context associated with them, in other words, you can't perform a redirect from them.