Re: [T5] - Parameter passing between Components.

2007-09-23 Thread Mohammad Shamsi
Hi Chris,

i write this sample layout, but i got exception,

here is my project structure :

resources/WEB-INF/
-- Start.html
--/test/components/Layout.html


src/test/pages
--Start.java
src/test/compoents
--Layout.java


when i run application i got this error on page :

An unexpected application exception has occurred.

   - java.lang.IllegalStateException This markup writer does not have a
   current element. The current element is established with the first call to
   element() and is maintained across subsequent calls.
   Stack trace
  -
  
org.apache.tapestry.internal.services.MarkupWriterImpl.ensureCurrentElement
  (MarkupWriterImpl.java:125)
  - org.apache.tapestry.internal.services.MarkupWriterImpl.write(
  MarkupWriterImpl.java:76)
  - org.apache.tapestry.internal.structure.TextPageElement.render(
  TextPageElement.java:34)
  - org.apache.tapestry.internal.services.RenderQueueImpl.run(
  RenderQueueImpl.java:57)
  -
  
org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup
  (PageMarkupRendererImpl.java:40)
  -
  
org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse
  (PageResponseRendererImpl.java:71)
  -
  org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle
  (PageRenderRequestHandlerImpl.java:81)
  -
  org.apache.tapestry.internal.services.RootPathDispatcher.dispatch
  (RootPathDispatcher.java:59)
  - org.apache.tapestry.services.TapestryModule$12.service(
  TapestryModule.java:1066)
  -
  org.apache.tapestry.internal.services.LocalizationFilter.service
  (LocalizationFilter.java:43)
  - org.apache.tapestry.services.TapestryModule$2.service(
  TapestryModule.java:657)
  -
  org.apache.tapestry.internal.services.StaticFilesFilter.service(
  StaticFilesFilter.java:63)
  -
  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke
  (CheckForUpdatesFilter.java:97)
  -
  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke
  (CheckForUpdatesFilter.java:88)
  -
  org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead
  (ConcurrentBarrier.java:77)
  -
  org.apache.tapestry.internal.services.CheckForUpdatesFilter.service
  (CheckForUpdatesFilter.java:110)
  - org.apache.tapestry.services.TapestryModule$11.service(
  TapestryModule.java:1044)
  - org.apache.tapestry.TapestryFilter.doFilter(
  TapestryFilter.java:135)
  -
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
  (ApplicationFilterChain.java:235)
  - org.apache.catalina.core.ApplicationFilterChain.doFilter(
  ApplicationFilterChain.java:206)
  - org.apache.catalina.core.StandardWrapperValve.invoke(
  StandardWrapperValve.java:228)
  - org.apache.catalina.core.StandardContextValve.invoke(
  StandardContextValve.java:175)
  - org.apache.catalina.core.StandardHostValve.invoke(
  StandardHostValve.java:128)
  - org.apache.catalina.valves.ErrorReportValve.invoke(
  ErrorReportValve.java:104)
  - org.apache.catalina.core.StandardEngineValve.invoke(
  StandardEngineValve.java:109)
  - org.apache.catalina.connector.CoyoteAdapter.service(
  CoyoteAdapter.java:216)
  - org.apache.coyote.http11.Http11Processor.process(
  Http11Processor.java:844)
  -
  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
  (Http11Protocol.java:634)
  - org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
  JIoEndpoint.java:445)
  - java.lang.Thread.run(Thread.java:595)

 Request Context Path/appRequest Path/Localeen_USHeaders
accepttext/xml,application/xml,application/xhtml+xml,text/html;q=0.9
,text/plain;q=0.8,image/png,*/*;q=0.5accept-charsetUTF-8,*accept-encoding
gzip,deflateaccept-languageen-us,en;q=0.5connectionkeep-alivehost
localhost:8080keep-alive300user-agentMozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7


On 9/23/07, Chris Lewis <[EMAIL PROTECTED]> wrote:
>
> Mohammad,
>
> Don't worry about your English. I just moved to a foreign country to
> learn the language, and its hard. I understand what you need so let's
> start with your layout component.
>
> First you'll need to read about component templates
> (http://tapestry.apache.org/tapestry5/tapestry-core/guide/templates.html).
> There is s section that covers layout components there. It's quite easy
> - basically you just make a normal (X)HTML template, and then where
> every you want the body to be displayed just use the  tag. For
> your layout you want to be able to supply a title as a parameter, so
> we'll do that. Assume your layout component is named "Layout" and this
> is your layout template:
>
> Layout.html:
>
> http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
> 
> *${title}*
> 
> 
> **
> 
> 
>

Re: [T5] - Parameter passing between Components.

2007-09-23 Thread Chris Lewis

Mohammad,

Don't worry about your English. I just moved to a foreign country to 
learn the language, and its hard. I understand what you need so let's 
start with your layout component.


First you'll need to read about component templates 
(http://tapestry.apache.org/tapestry5/tapestry-core/guide/templates.html). 
There is s section that covers layout components there. It's quite easy 
- basically you just make a normal (X)HTML template, and then where 
every you want the body to be displayed just use the  tag. For 
your layout you want to be able to supply a title as a parameter, so 
we'll do that. Assume your layout component is named "Layout" and this 
is your layout template:


Layout.html:

http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
   
   *${title}*
   
   
   **
   


That's it for the template. Whenever you use this layout your page 
content will replace the  tag. You'd use it in a page named 
Start like this:


Start.html

http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
   Your page content here.


Now you need a component class for your layout so that it accepts a 
title parameter. Here's Layout.java:


public class Layout {

   //This annotation says that this component has a parameter named 
"title".

   @Parameter
   private String title;

   /**
* A getter for the title, so we can use ${title} in the template.
* @return the title
*/
   public String getTitle() {
   return title;
   }

}

That's it. Now revise your Start page to supply a title to the layout:

Start.html

http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"; 
*title="literal:Start Page"*>

   Your page content here.


Here we use the "literal" binding prefix to pass the string "Start Page" 
to the layout component's title. If you want to use a method on the 
start page to generate the title (like getPageTitle), then create a 
method named getPageTitle that returns your title, and use ${pageTitle} 
for the parameter.


Read up on component templates and classes, you'll get it.

To centralize your query logic you probably need your entities to extend 
a class that implements the search in a generic way. You'll have to 
figure that one out or someone else can help here - that's not really a 
Tapestry concern. To centralize the call to the entity/service search 
method, you probably need to include the search form (possibly with 
dynamic parameters?) in your component, and then have the event handler 
for the "Search" button retrieve the entity/service interface, so it can 
then call the search on the underlying entity.


Other comments welcome here :).

hope this helps!

chris

Mohammad Shamsi wrote:

Hi Chris,

sorry for my pour English, i try to explain it completely.

we have two pages, each pages has its entity and probably its search
parameteres
in first entity i want to search  X and Y properties.
and in second entity i want to search Z, V and W properties

each entity has its Service that implement the search method,

first -  i want to design a layout that let me have 2 dynamic parts, the
first part for search parameters and the second part for show result, i
don't now hot to build layout in T5

second -  when search event fired it most gather parameters and call search
pages service
i want a write abstract code to use in both pages.




On 9/23/07, Chris Lewis <[EMAIL PROTECTED]> wrote:
  

Hi Mohammad,

I'm not sure I completely understand. I think you have created a
component for rendering your search results, and I assume you have
created it to accept a parameter containing the results to display. So
you should be able to use it like this in your templates:

...



...

This assumes that you have a component named "SearchResults" and it
receives a Collection (List, Set, etc) of results in a parameter named
"results".
If you already have this, and your component implements your display
logic for the results, then you won't really be repeating any code. Of
course you may be talking about the logic to get your results, but I'm
not sure.

Perhaps if you could explain a bit more, I could offer better help.

good luck!

Mohammad Shamsi wrote:


Dear friends,

i have a  search box in my page layout, and a component for show list of
items (like table and grid)

i want to send  search result to  my grid component to show them, but i
don't know how to do it

i need it in all of my pages, and i don't want to repeat code in all
  

pages.


any idea ?


  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






  




Re: [T5] - Parameter passing between Components.

2007-09-23 Thread Mohammad Shamsi
Hi Chris,

sorry for my pour English, i try to explain it completely.

we have two pages, each pages has its entity and probably its search
parameteres
in first entity i want to search  X and Y properties.
and in second entity i want to search Z, V and W properties

each entity has its Service that implement the search method,

first -  i want to design a layout that let me have 2 dynamic parts, the
first part for search parameters and the second part for show result, i
don't now hot to build layout in T5

second -  when search event fired it most gather parameters and call search
pages service
i want a write abstract code to use in both pages.




On 9/23/07, Chris Lewis <[EMAIL PROTECTED]> wrote:
>
> Hi Mohammad,
>
> I'm not sure I completely understand. I think you have created a
> component for rendering your search results, and I assume you have
> created it to accept a parameter containing the results to display. So
> you should be able to use it like this in your templates:
>
> ...
> 
> 
> 
> ...
>
> This assumes that you have a component named "SearchResults" and it
> receives a Collection (List, Set, etc) of results in a parameter named
> "results".
> If you already have this, and your component implements your display
> logic for the results, then you won't really be repeating any code. Of
> course you may be talking about the logic to get your results, but I'm
> not sure.
>
> Perhaps if you could explain a bit more, I could offer better help.
>
> good luck!
>
> Mohammad Shamsi wrote:
> > Dear friends,
> >
> > i have a  search box in my page layout, and a component for show list of
> > items (like table and grid)
> >
> > i want to send  search result to  my grid component to show them, but i
> > don't know how to do it
> >
> > i need it in all of my pages, and i don't want to repeat code in all
> pages.
> >
> > any idea ?
> >
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
sincerely yours
M. H. Shamsi


Re: [T5] - Parameter passing between Components.

2007-09-23 Thread Chris Lewis

Hi Mohammad,

I'm not sure I completely understand. I think you have created a 
component for rendering your search results, and I assume you have 
created it to accept a parameter containing the results to display. So 
you should be able to use it like this in your templates:


...

   

...

This assumes that you have a component named "SearchResults" and it 
receives a Collection (List, Set, etc) of results in a parameter named 
"results".
If you already have this, and your component implements your display 
logic for the results, then you won't really be repeating any code. Of 
course you may be talking about the logic to get your results, but I'm 
not sure.


Perhaps if you could explain a bit more, I could offer better help.

good luck!

Mohammad Shamsi wrote:

Dear friends,

i have a  search box in my page layout, and a component for show list of
items (like table and grid)

i want to send  search result to  my grid component to show them, but i
don't know how to do it

i need it in all of my pages, and i don't want to repeat code in all pages.

any idea ?

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]