You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Amol Yadwadkar <ay...@webifyservices.com> on 2003/06/17 09:48:12 UTC

Getting the parametrs from URLs

Hi All,
I am walking few Baby Steps to develop Tapestry Application.
What I have did till now is as follows:-

1>> I have Login Page.
2>> On Clicking the Button  We are naviagated to the Second Page where all the entered values in TextBoxes (of the first Page) are diplayed.

The help Needed from u all will be:-
1>> I need to provid some check on Username/password which r entered in the textBoxes.
and I am stuck at this as I am not getting of as how  to get the  Parameters from url   (request.getParameter(""))  in Tapestry.
Can Any one solve my Problems?

Thanlkx.
Amol


Re: Getting the parametrs from URLs

Posted by Harish Krishnaswamy <hk...@comcast.net>.
You mat find a similar demo app at 
http://mywebpages.comcast.net/hkrishnaswamy/.

Thanks
Harish

Amol Yadwadkar wrote:

>Hi All,
>I am walking few Baby Steps to develop Tapestry Application.
>What I have did till now is as follows:-
>
>1>> I have Login Page.
>2>> On Clicking the Button  We are naviagated to the Second Page where all the entered values in TextBoxes (of the first Page) are diplayed.
>
>The help Needed from u all will be:-
>1>> I need to provid some check on Username/password which r entered in the textBoxes.
>and I am stuck at this as I am not getting of as how  to get the  Parameters from url   (request.getParameter(""))  in Tapestry.
>Can Any one solve my Problems?
>
>Thanlkx.
>Amol
>
>
>  
>



Re: Getting the parametrs from URLs

Posted by Mindbridge <mi...@yahoo.com>.
Hi Amol,

> I need to provid some check on Username/password which r entered in the
textBoxes.
> and I am stuck at this as I am not getting of as how  to get the
> Parameters from url   (request.getParameter(""))  in Tapestry.

This is the JSP way of doing things. The Tapestry approach is quite
different.

The idea is that in the java class (bean) of your page you provide
properties, that you then 'bind' to the components you use. The components
are responsible for filling in your properties with the values you need.

For example, a simple implementation of what you described would be the
following:

MyPage.html
--------------
....
<form jwcid="@Form">
    ....
    Username: <input jwcid="@TextField" value="ognl:username"/><br>
    Password: <input jwcid="@TextField" value="ognl:password"
hidden="ognl:true"/><br>
    ......
    <input jwcid="@Submit" label="Login" listener="ognl:listeners.login"/>
</form>

The above input fields are essentially "bound" to the 'username' and
'password' properties of the page object.
An here is how one could implement that (you are using 3.0, I presume):

MyPage.java
--------------
public class MyPage extends BasePage
{
    // these are your properies
    private String  _username;
    private String  _password;

    // and these are their standard accessors
    public String getUsername() { return _username; }
    public void setUsername(String username) { _username = username; }
    public String getPassword() { return _password; }
    public void setPassword(String password) { _password = password; }

    // all of the above can be defined with a single line per property in
the page file, but I am putting those here for clarity

    // define the standard values of all properties -- this is important
    public void initialize() {
        _username = "";
        _password = "";
    }

    // define the method to be invoked when the Login button is pressed
    public void login(IRequestCycle cycle) {
        // when this listener is invoked, the properties above would have
their values automatically set
        if (/*username/password combination is correct*/) {
            // switch to the other page.
            // note! passing data between pages is typically NOT done by
passing parameters in the URL like in JSP, but instead it is passed simply
as objects by invoking methods in the normal Java way:
            AnotherPage page = (AnotherPage) cycle.getPage("AnotherPage");
            page.invokeSomeMethod(..);        // only if necessary, of
course
            page.passSomeParameters(...);
            cycle.activate(page);
        }

        // invalid user/pass -- display an error -- see chapter on form
delegates in the developer guide for an example
    }

}


For future development please have a quick look at the Developer's guide
(http://jakarta.apache.org/tapestry/doc/DevelopersGuide/DevelopersGuide.html
) and/or the tutorial and the Vlib application that came with the
distribution for more info. The documents are both written for 2.x, rather
than 3.0, but the content is valid and describes the basic concepts well. In
addition, the Component Reference
(http://jakarta.apache.org/tapestry/doc/ComponentReference/index.html) is
your friend -- it describes the standard components and their parameters -- 
very useful when developing stuff.


I hope this helps.

Best regards,
-mb