Re: is there a way to get the hostname:port and IP address

2013-03-17 Thread Bob Harner
The Tapestry-related answer is that Tapestry provides an injectable
service, Request [1],  that is a shadow of the current thread's
HTTPServletRequest [2]:

import org.apache.tapestry5.services.Request;
@Inject
Request request;
public String getRemoteHost() {
return request.getRemoteHost();
}
public int getLocalPort() {
return request.getLocalPort();
}

but since Request only has a subset of the properties that
HTTPServletRequest offers, for many purposes you'll need to directly
access HTTPServletRequest directly, which you can also inject:

import javax.servlet.http.HttpServletRequest;
@Inject
private HttpServletRequest httpServletRequest;
public String getRemoteAddr() {
return httpServletRequest.getRemoteAddr();
}

Be sure the servlet API is on your classpath. If using Maven, for example:

!-- Provided by the servlet container, but sometimes referenced in
the application code. --
dependency
groupIdjavax.servlet/groupId
artifactIdservlet-api/artifactId
version2.5/version
scopeprovided/scope
/dependency

Also note that if you have a separate web server (e.g. Apache HTTP)
in front of your app server, it may or may not be configured to pass
the correct client information to the app.

[1] 
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Request.html
[2] 
http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html

On Sat, Mar 16, 2013 at 5:32 PM, Ivan Khalopik ikhalo...@gmail.com wrote:
 It is not a tapestry question.

 http://docs.oracle.com/javaee/5/api/javax/servlet/ServletRequest.html

 On Sat, Mar 16, 2013 at 11:42 PM, nhhockeyplayer nashua
 nhhockeypla...@hotmail.com wrote:
 Folks,

 I want to track my users. Is there a way to get host:port and ip ?

 Best regards
 and thanks... KEN



 --
 BR
 Ivan

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


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



Re: Read only bindings - How do I set their value from a mixin?

2013-03-17 Thread Rusty Phillips
On Mar 13, 2013 4:52 AM, Lance Java lance.j...@googlemail.com wrote:

 In a mixin, I can change the value of a component parameter using:..
 @BindParameter to get a mirror of the parameter and then updating the
 mirrored value.

 This is fine with the prop: and var: bindings since they are read/write
 bindings. If I try this with a parameter which is bound to symbol: or
 literal: the update fails with Binding %s is read-only (originating from
 AbstractBinding).

 Is there any way that I can change a component parameter that is bound to
 literal: or symbol: from a mixin?



 --
 View this message in context:
http://tapestry.1045711.n5.nabble.com/Read-only-bindings-How-do-I-setw,-their-value-from-a-mixin-tp5720446.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Streaming a binary file - IllegalArgumentException

2013-03-17 Thread Sigbjørn Tvedt
Hi

As Bob Harner said, the img tag you are using is a normal html tag that
takes a url.
If you look at the example you are linking to, you will see that it is
using 2 different classes (UploadStore and SomePage)

These pages have different tasks.
UpploadStore redenders a image based on the ID in the activation
contextwhile SomePage is the page beeing displayed.


You should therefore create a page (without the tml file) that returns the
binary content when it is activated (you may test this by pointing your
browser to it. ) and then link to it from your index page.


Regards

Sigbjørn Tvedt

On 17 March 2013 01:19, Bob Harner bobhar...@gmail.com wrote:

 The src attribute of the img element requires the URL of the image, not the
 image contents.
 On Mar 16, 2013 7:46 PM, Bela Takacs bela.takacs@gmail.com wrote:

  Hi All,
 
  I am writing my very first program using Tapestry, and I've got my
  first problem...
 
  I want to display an image in my Index.tml template, so I'm trying to
  use two files (InlineStreamResponse.java and JPEGInline.java) from
  here:
  http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
 
  Firefox an IE can display my template but neither Firefox nor IE can
  display the images (I cannot see any images on the screen). I got the
  following error message in my Eclipse/Jetty console
  (IllegalArgumentException: '@' character is not valid), but I do not
  use any '@' character:
 
  [INFO] AppModule.TimingFilter Request time: 2 ms
  [INFO] AppModule.TimingFilter Request time: 3 ms
  [ERROR] TapestryModule.RequestExceptionHandler Processing of request
  failed with uncaught exception: Input string
  'com.example.tutorial.pictureHandler.JPEGInline@608a6351' is not
  valid; the character '@' at position 47 is not valid.
  java.lang.IllegalArgumentException: Input string
  'com.example.tutorial.pictureHandler.JPEGInline@608a6351' is not
  valid; the character '@' at position 47 is not valid.
  at
 
 org.apache.tapestry5.internal.services.URLEncoderImpl.decode(URLEncoderImpl.java:144)
  at $URLEncoder_6d6aa2f29b30.decode(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.ContextPathEncoderImpl.decodePath(ContextPathEncoderImpl.java:92)
  at $ContextPathEncoder_6d6aa2f29b18.decodePath(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.ComponentEventLinkEncoderImpl.checkIfPage(ComponentEventLinkEncoderImpl.java:501)
  at
 
 org.apache.tapestry5.internal.services.ComponentEventLinkEncoderImpl.decodePageRenderRequest(ComponentEventLinkEncoderImpl.java:475)
  at
 
 org.apache.tapestry5.internal.services.linktransform.LinkTransformerInterceptor.decodePageRenderRequest(LinkTransformerInterceptor.java:68)
  at
  $ComponentEventLinkEncoder_6d6aa2f29b0c.decodePageRenderRequest(Unknown
  Source)
  at
 
 org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:41)
  at $Dispatcher_6d6aa2f29b0d.dispatch(Unknown Source)
  at $Dispatcher_6d6aa2f29b07.dispatch(Unknown Source)
  at
 
 org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
  at
 
 org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at
 
 org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:902)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at
 
 org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:892)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at
  com.example.tutorial.services.AppModule$1.service(AppModule.java:89)
  at $RequestFilter_6d6aa2f29b02.service(Unknown Source)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:105)
  at
 
 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:95)
  at
 
 org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
  at
 
 org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
  at $RequestHandler_6d6aa2f29b08.service(Unknown Source)
  at $RequestHandler_6d6aa2f29afb.service(Unknown Source)
  at
 
 org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
  at
  org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
  at $HttpServletRequestHandler_6d6aa2f29afd.service(Unknown
 

RE: is there a way to get the hostname:port and IP address

2013-03-17 Thread nhhockeyplayer nashua
Thanks Bob... awesome answer... blows the others right off the boards.

I wish your development opens up for a breakout and terrific designs to follow.

- cheers

Best regards 
and thanks... KEN

From: nhhockeypla...@hotmail.com
To: users@tapestry.apache.org
Subject: is there a way to get the hostname:port and IP address
Date: Sat, 16 Mar 2013 16:42:41 -0400




Folks,

I want to track my users. Is there a way to get host:port and ip ?

Best regards 
and thanks... KEN   
  

Re: Streaming a binary file - IllegalArgumentException

2013-03-17 Thread Bela Takacs
Hi Sigbjørn, Hi Bob,

Yeah, I think, I get the idea.

So, if you want to use the HTML img tag for streaming, you need a
org.apache.tapestry5.Link (for example, it can be created by a
componentResources.createEventLink(image, id)) or you need to inject
a LinkSource (just as in the UploadStore example), and use the
createPageRenderLink method, because you cannot stream the
BufferedImage object directly.

Thank you both very much for your help. You have solved my first
Tapestry problem in my life. :)

It is not impossible, that someone might be interested in the
solution, so I paste my code here. It uses my Hello1.jpg, Hello2.jpg,
Hello3.jpg and Hello4.jpg, depending on the address.id and pastes them
into a Grid component.


Index.tml:


t:grid source=addresses row=address include=city, image
  p:cityCell
 div id=CellItem_1
 t:pagelink page=about
context=address.id${address.firstName}/t:pagelink
 /div
  /p:cityCell
  p:imageCell
   img src=${getImageLink(address.id)} alt=the image
should be here /
  /p:imageCell
  /t:grid


-
Index.java:
-

  public Link getImageLink(int id) {
  return this.componentResources.createEventLink(image, id);
  }

  StreamResponse onImage(final int i) {
return new StreamResponse() {
  public String getContentType() {return image/jpeg;}
  public InputStream getStream() throws IOException {   
  File fnew=new File(d:\\Hello + i + .jpg); 
  BufferedImage originalImage=ImageIO.read(fnew);
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  ImageIO.write(originalImage, jpg, baos );   
  return new ByteArrayInputStream(baos.toByteArray());
  }
  public void prepareResponse(final Response response) {}
};
}


Now, I will try to read my JPG Images from my Hibernate/MySql database
and place them into the above mentioned Grid component.

Have a nice day!
Bela


2013/3/17, Sigbjørn Tvedt sigbjo...@gmail.com:
 Hi

 As Bob Harner said, the img tag you are using is a normal html tag that
 takes a url.
 If you look at the example you are linking to, you will see that it is
 using 2 different classes (UploadStore and SomePage)

 These pages have different tasks.
 UpploadStore redenders a image based on the ID in the activation
 contextwhile SomePage is the page beeing displayed.


 You should therefore create a page (without the tml file) that returns the
 binary content when it is activated (you may test this by pointing your
 browser to it. ) and then link to it from your index page.


 Regards

 Sigbjørn Tvedt

 On 17 March 2013 01:19, Bob Harner bobhar...@gmail.com wrote:

 The src attribute of the img element requires the URL of the image, not
 the
 image contents.
 On Mar 16, 2013 7:46 PM, Bela Takacs bela.takacs@gmail.com wrote:

  Hi All,
 
  I am writing my very first program using Tapestry, and I've got my
  first problem...
 
  I want to display an image in my Index.tml template, so I'm trying to
  use two files (InlineStreamResponse.java and JPEGInline.java) from
  here:
  http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
 
  Firefox an IE can display my template but neither Firefox nor IE can
  display the images (I cannot see any images on the screen). I got the
  following error message in my Eclipse/Jetty console
  (IllegalArgumentException: '@' character is not valid), but I do not
  use any '@' character:
 
  [INFO] AppModule.TimingFilter Request time: 2 ms
  [INFO] AppModule.TimingFilter Request time: 3 ms
  [ERROR] TapestryModule.RequestExceptionHandler Processing of request
  failed with uncaught exception: Input string
  'com.example.tutorial.pictureHandler.JPEGInline@608a6351' is not
  valid; the character '@' at position 47 is not valid.
  java.lang.IllegalArgumentException: Input string
  'com.example.tutorial.pictureHandler.JPEGInline@608a6351' is not
  valid; the character '@' at position 47 is not valid.
  at
 
 org.apache.tapestry5.internal.services.URLEncoderImpl.decode(URLEncoderImpl.java:144)
  at $URLEncoder_6d6aa2f29b30.decode(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.ContextPathEncoderImpl.decodePath(ContextPathEncoderImpl.java:92)
  at $ContextPathEncoder_6d6aa2f29b18.decodePath(Unknown Source)
  at
 
 org.apache.tapestry5.internal.services.ComponentEventLinkEncoderImpl.checkIfPage(ComponentEventLinkEncoderImpl.java:501)
  at
 
 org.apache.tapestry5.internal.services.ComponentEventLinkEncoderImpl.decodePageRenderRequest(ComponentEventLinkEncoderImpl.java:475)
  at
 
 org.apache.tapestry5.internal.services.linktransform.LinkTransformerInterceptor.decodePageRenderRequest(LinkTransformerInterceptor.java:68)
  at
  $ComponentEventLinkEncoder_6d6aa2f29b0c.decodePageRenderRequest(Unknown

Re: TapestryIoC: Is it possible to receive an OrderedConfiguration's ID?

2013-03-17 Thread Steve Eynon
Nothing specific that I know of...

...you could iterate over the ServiceActivities in the
ServiceActivityScoreboard service looking for a matching service
interface and take the ID from there. It's not nice, but as long as
you know the type of the service, it should work.

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