You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@gmail.com> on 2007/10/10 13:01:46 UTC

T5: A component returning StreamResponse?

Hello,

I would like to create an ajax dialog (actually a series of them to act as a
wizard). The content of the dialog should change according to user
interaction and therefore create a series of steps. If this wizard is going
to have 3 steps then 3 ajax requests for dialog content would be made.

I would like each ajax request to call (different) T5 component returning
HTML fragment.

I am using jQuery to make a request

***** TEMPLATE ******
        <script>
            $().ready(function() {
              $('#ex2').jqm({ajax: '${thelink}'}).jqmShow();
            });
        </script>

***** CLASS *****
    public String getTheLink() {
        Link l = _resources.createActionLink("myAction", false);
        return l.toURI();
    }

    StreamResponse onMyAction() {
        String htmlFragment = "<p>paragraph <b>bold</b></p>";
        return new TextStreamResponse("text/html", htmlFragment);
    }


I would like the htmlFragment to be generated by T5 component for example
WizardStep1.

If I declare a component in the class above:
    @Component
    private WizardStep1 wizardStep1;

and modify method onMyAction like this

    StreamResponse onMyAction() {
        wizardStep1.setMessage("hello");
        return (StreamResponse) wizardStep1;
    }

then I get Exception:
Component ui/dialog/JQModalAjax does not contain an embedded component with
id 'wizardStep1'.

which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml


Any suggestions?

RE: T5: A component returning StreamResponse?

Posted by Waldo Mendoza <wa...@coderoad.com>.
Sorry, forgot to mention that in WizardPage.tml should be a actionlink component
 
<a t:id="stepChanged" t:type="actionlink"/>
 
and the handler method should be
 
void onActionFromStepChanged(String toPage) {
  _currentPage = toPage;
}
 
The Ajax request can be done:
 
new Ajax.Request('/context/wizardpage.stepchanged/step2', {
  method: 'GET',
  onSuccess: function (t) {
  //really nothing to do here
  }
});

 
________________________________

From: Waldo Mendoza [mailto:waldo@coderoad.com]
Sent: Wed 10/10/2007 11:44 AM
To: Tapestry users
Subject: RE: T5: A component returning StreamResponse?



Hi there!

Why not instead of a component the htmlFragment comes from a Page?, so in your javascript code, you can make a page request.

For example, in my Main Page:

class WizardPage {
  @Persist
  private String _currentPage;

  void onStepChanged(String toPage) {
    _currentPage = toPage;
  }
}

Then the javascript code can use that property to render the actual step.

new Ajax.Request('GET', ${currentPage}, {
   onSuccess: function (transport) {
      var replaceElement = $(...);
      replaceElement.innerHTML = transport.responseText;
      //load scripts as necessary.
    }
});

${currentPage} can be a string that the ComponentResources generates, just a detail that you already used.

And of course there should be a chain of pages to take in account.

________________________________

From: Borut Bolcina [mailto:borut.bolcina@gmail.com]
Sent: Wed 10/10/2007 7:01 AM
To: Tapestry
Subject: T5: A component returning StreamResponse?



Hello,

I would like to create an ajax dialog (actually a series of them to act as a
wizard). The content of the dialog should change according to user
interaction and therefore create a series of steps. If this wizard is going
to have 3 steps then 3 ajax requests for dialog content would be made.

I would like each ajax request to call (different) T5 component returning
HTML fragment.

I am using jQuery to make a request

***** TEMPLATE ******
        <script>
            $().ready(function() {
              $('#ex2').jqm({ajax: '${thelink}'}).jqmShow();
            });
        </script>

***** CLASS *****
    public String getTheLink() {
        Link l = _resources.createActionLink("myAction", false);
        return l.toURI();
    }

    StreamResponse onMyAction() {
        String htmlFragment = "<p>paragraph <b>bold</b></p>";
        return new TextStreamResponse("text/html", htmlFragment);
    }


I would like the htmlFragment to be generated by T5 component for example
WizardStep1.

If I declare a component in the class above:
    @Component
    private WizardStep1 wizardStep1;

and modify method onMyAction like this

    StreamResponse onMyAction() {
        wizardStep1.setMessage("hello");
        return (StreamResponse) wizardStep1;
    }

then I get Exception:
Component ui/dialog/JQModalAjax does not contain an embedded component with
id 'wizardStep1'.

which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml


Any suggestions?







RE: T5: A component returning StreamResponse?

Posted by Waldo Mendoza <wa...@coderoad.com>.
Hi there!
 
Why not instead of a component the htmlFragment comes from a Page?, so in your javascript code, you can make a page request.
 
For example, in my Main Page:
 
class WizardPage {
  @Persist
  private String _currentPage;
 
  void onStepChanged(String toPage) {
    _currentPage = toPage;
  }
}
 
Then the javascript code can use that property to render the actual step.
 
new Ajax.Request('GET', ${currentPage}, {
   onSuccess: function (transport) {
      var replaceElement = $(...);
      replaceElement.innerHTML = transport.responseText;
      //load scripts as necessary.
    }
});
 
${currentPage} can be a string that the ComponentResources generates, just a detail that you already used.

And of course there should be a chain of pages to take in account.
 
________________________________

From: Borut Bolcina [mailto:borut.bolcina@gmail.com]
Sent: Wed 10/10/2007 7:01 AM
To: Tapestry
Subject: T5: A component returning StreamResponse?



Hello,

I would like to create an ajax dialog (actually a series of them to act as a
wizard). The content of the dialog should change according to user
interaction and therefore create a series of steps. If this wizard is going
to have 3 steps then 3 ajax requests for dialog content would be made.

I would like each ajax request to call (different) T5 component returning
HTML fragment.

I am using jQuery to make a request

***** TEMPLATE ******
        <script>
            $().ready(function() {
              $('#ex2').jqm({ajax: '${thelink}'}).jqmShow();
            });
        </script>

***** CLASS *****
    public String getTheLink() {
        Link l = _resources.createActionLink("myAction", false);
        return l.toURI();
    }

    StreamResponse onMyAction() {
        String htmlFragment = "<p>paragraph <b>bold</b></p>";
        return new TextStreamResponse("text/html", htmlFragment);
    }


I would like the htmlFragment to be generated by T5 component for example
WizardStep1.

If I declare a component in the class above:
    @Component
    private WizardStep1 wizardStep1;

and modify method onMyAction like this

    StreamResponse onMyAction() {
        wizardStep1.setMessage("hello");
        return (StreamResponse) wizardStep1;
    }

then I get Exception:
Component ui/dialog/JQModalAjax does not contain an embedded component with
id 'wizardStep1'.

which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml


Any suggestions?




Re: T5: A component returning StreamResponse?

Posted by Britske <gb...@gmail.com>.
Not sure if you solved this already, but anyway:  
Regarding the exception you got: 


Borut Bolčina-2 wrote:
> 
> then I get Exception:
> Component ui/dialog/JQModalAjax does not contain an embedded component
> with
> id 'wizardStep1'.
> 
> which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml
> 

As a workaround it's possible to define Wizarstep1 in a block in
JQModalAjax.tml, like so: 

<t:block>
	<t:WizardStep1 id="wizardstep1/>
</t:block>

Since the wizardstep component is included in the block it isn't rendered in
JQModalAjax.tml unless explicitly asked to do so. Now you should be able to
do what you wanted without exceptions.

Cheers,
Geert-Jan





Borut Bolčina-2 wrote:
> 
> Hello,
> 
> I would like to create an ajax dialog (actually a series of them to act as
> a
> wizard). The content of the dialog should change according to user
> interaction and therefore create a series of steps. If this wizard is
> going
> to have 3 steps then 3 ajax requests for dialog content would be made.
> 
> I would like each ajax request to call (different) T5 component returning
> HTML fragment.
> 
> I am using jQuery to make a request
> 
> ***** TEMPLATE ******
>         <script>
>             $().ready(function() {
>               $('#ex2').jqm({ajax: '${thelink}'}).jqmShow();
>             });
>         </script>
> 
> ***** CLASS *****
>     public String getTheLink() {
>         Link l = _resources.createActionLink("myAction", false);
>         return l.toURI();
>     }
> 
>     StreamResponse onMyAction() {
>         String htmlFragment = "<p>paragraph bold</p>";
>         return new TextStreamResponse("text/html", htmlFragment);
>     }
> 
> 
> I would like the htmlFragment to be generated by T5 component for example
> WizardStep1.
> 
> If I declare a component in the class above:
>     @Component
>     private WizardStep1 wizardStep1;
> 
> and modify method onMyAction like this
> 
>     StreamResponse onMyAction() {
>         wizardStep1.setMessage("hello");
>         return (StreamResponse) wizardStep1;
>     }
> 
> then I get Exception:
> Component ui/dialog/JQModalAjax does not contain an embedded component
> with
> id 'wizardStep1'.
> 
> which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml
> 
> 
> Any suggestions?
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-A-component-returning-StreamResponse--tf4600101.html#a13575865
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: A component returning StreamResponse?

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
hi borut,

what you need is not possible... we'll have to wait for the AJAX
integration :)

i've posted a have-baked solution how to perform partial 
page rendering in t5:

http://www.nabble.com/T5%3A-Prototype%27s-AJAX.updater-question-tf3907697.html#a11079706

it works as long there is no Form component involved. if 
so you have to put some services (eg. FormSupport,...) 
into the Environment manually and maintain the form state 
replacing the "t:formdata" input field generated with every form.

g,
kris




"Borut Bolčina" <bo...@gmail.com> 
10.10.2007 13:01
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry <us...@tapestry.apache.org>
Kopie

Thema
T5: A component returning StreamResponse?






Hello,

I would like to create an ajax dialog (actually a series of them to act as 
a
wizard). The content of the dialog should change according to user
interaction and therefore create a series of steps. If this wizard is 
going
to have 3 steps then 3 ajax requests for dialog content would be made.

I would like each ajax request to call (different) T5 component returning
HTML fragment.

I am using jQuery to make a request

***** TEMPLATE ******
        <script>
            $().ready(function() {
              $('#ex2').jqm({ajax: '${thelink}'}).jqmShow();
            });
        </script>

***** CLASS *****
    public String getTheLink() {
        Link l = _resources.createActionLink("myAction", false);
        return l.toURI();
    }

    StreamResponse onMyAction() {
        String htmlFragment = "<p>paragraph <b>bold</b></p>";
        return new TextStreamResponse("text/html", htmlFragment);
    }


I would like the htmlFragment to be generated by T5 component for example
WizardStep1.

If I declare a component in the class above:
    @Component
    private WizardStep1 wizardStep1;

and modify method onMyAction like this

    StreamResponse onMyAction() {
        wizardStep1.setMessage("hello");
        return (StreamResponse) wizardStep1;
    }

then I get Exception:
Component ui/dialog/JQModalAjax does not contain an embedded component 
with
id 'wizardStep1'.

which is true, as I don't have WizardStep1 in my ui/dialog/JQModalAjax.tml


Any suggestions?