You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Qbyte Consulting <qb...@gmail.com> on 2016/12/16 08:53:06 UTC

Tapestry w Scala

Hi,

Has anyone implemented a T5.4 site with Scala, or are there any kickstart
type Scala projects out there for T5.4 please? I'd like to see how it's
done.

John

Re: Tapestry w Scala

Posted by Ilya Obshadko <il...@gmail.com>.
I use mixed Java/Scala code for pages, components and services without any
issues.
To pass collections you need to either convert them to Java collections
(calling .asJava), or contribute to type coercer:

def createTapestryCoercions(configuration:
org.apache.tapestry5.ioc.Configuration[org.apache.tapestry5.ioc.services.CoercionTuple[_,
java.lang.Iterable[_]]]) = {
  val coercion = new Coercion[Iterable[AnyRef], java.lang.Iterable[_]] () {
    def coerce(arg: Iterable[AnyRef]) = arg.asJava
  }

  configuration.add(new CoercionTuple(classOf[Iterable[AnyRef]],
classOf[java.lang.Iterable[_]], coercion))
}



On Fri, Dec 16, 2016 at 4:53 PM, Qbyte Consulting <qbyteconsulting@gmail.com
> wrote:

> Hi,
>
> Has anyone implemented a T5.4 site with Scala, or are there any kickstart
> type Scala projects out there for T5.4 please? I'd like to see how it's
> done.
>
> John
>



-- 
Ilya Obshadko

Re: jquery-ui.css and CSSURLRewriter

Posted by Bob Harner <bo...@gmail.com>.
As you probably figured out, Tapestry's parsing of CSS files is just
using a regular expression rather than a true parser, and coming up
with a regex that skipped urls within comments was judged too hard at
the time (https://issues.apache.org/jira/browse/TAP5-2368). However,
it looks like you're right, AssetSourceImpl.getAsset is throwing a
RuntimeException when the asset is not found, but Tapestry is
erroneously checking for a null instead of catching an exception in
that case (CSSURLRewriter.java:179), breaking effective use of the
STRICT_CSS_URL_REWRITING symbol.

Care to file a bug? (A patch would be nice too!)

https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java

On Tue, Dec 20, 2016 at 3:42 PM, Robert Hannebauer
<ro...@hannebauer.org> wrote:
> Hello,
>
> i'm playing with webjars (https://github.com/eddyson-de/tapestry-webjars) and jquery-ui. Everything work fine, except when i try to use the jquery-ui.css.
>
> It took me some time to understand the following error message, while trying to load the css file:
>
> Caused by: java.lang.RuntimeException: Unable to locate asset 'webjars:META-INF/resources/webjars/jquery-ui/1.12.1/%22images%2Fui-icons_555555_256x240.png%22'
> (the file does not exist).
>     at org.apache.tapestry5.internal.services.AssetSourceImpl.getLocalizedAssetFromResource(AssetSourceImpl.java:390)
>     at org.apache.tapestry5.internal.services.AssetSourceImpl.getAssetInLocale(AssetSourceImpl.java:305)
>     at org.apache.tapestry5.internal.services.AssetSourceImpl.getAsset(AssetSourceImpl.java:131)
>     at $AssetSource_25dc8e7415b4a.getAsset(Unknown Source)
>     at org.apache.tapestry5.internal.services.assets.CSSURLRewriter.replaceURLs(CSSURLRewriter.java:177)
>     at org.apache.tapestry5.internal.services.assets.CSSURLRewriter.access$100(CSSURLRewriter.java:46)
>     at org.apache.tapestry5.internal.services.assets.CSSURLRewriter$1.perform(CSSURLRewriter.java:109)
>     at org.apache.tapestry5.internal.services.assets.CSSURLRewriter$1.perform(CSSURLRewriter.java:104)
>     at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.perform(OperationTrackerImpl.java:110)
>
> The file %22images%2Fui-icons_555555_256x240.png%22  does really not exists.
>
> Playing with SymbolConstants.STRICT_CSS_URL_REWRITING does not really help, because the CSSURLRewriter fails too early.
>
> The root cause is the *comment* header of  jquery-ui.css. Within this header exists the string "url(%22images%2Fui-icons_555555_256x240.png%22)".
> I assume, it would be a good idea to either ignore comments or to be more tolerant or catch the exception and then evaluate STRICT_CSS_URL_REWRITING.
> What do you think?
>
> Regards,
> Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


jquery-ui.css and CSSURLRewriter

Posted by Robert Hannebauer <ro...@hannebauer.org>.
Hello,

i'm playing with webjars (https://github.com/eddyson-de/tapestry-webjars) and jquery-ui. Everything work fine, except when i try to use the jquery-ui.css.

It took me some time to understand the following error message, while trying to load the css file:

Caused by: java.lang.RuntimeException: Unable to locate asset 'webjars:META-INF/resources/webjars/jquery-ui/1.12.1/%22images%2Fui-icons_555555_256x240.png%22'
(the file does not exist).
    at org.apache.tapestry5.internal.services.AssetSourceImpl.getLocalizedAssetFromResource(AssetSourceImpl.java:390)
    at org.apache.tapestry5.internal.services.AssetSourceImpl.getAssetInLocale(AssetSourceImpl.java:305)
    at org.apache.tapestry5.internal.services.AssetSourceImpl.getAsset(AssetSourceImpl.java:131)
    at $AssetSource_25dc8e7415b4a.getAsset(Unknown Source)
    at org.apache.tapestry5.internal.services.assets.CSSURLRewriter.replaceURLs(CSSURLRewriter.java:177)
    at org.apache.tapestry5.internal.services.assets.CSSURLRewriter.access$100(CSSURLRewriter.java:46)
    at org.apache.tapestry5.internal.services.assets.CSSURLRewriter$1.perform(CSSURLRewriter.java:109)
    at org.apache.tapestry5.internal.services.assets.CSSURLRewriter$1.perform(CSSURLRewriter.java:104)
    at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.perform(OperationTrackerImpl.java:110)

The file %22images%2Fui-icons_555555_256x240.png%22  does really not exists.

Playing with SymbolConstants.STRICT_CSS_URL_REWRITING does not really help, because the CSSURLRewriter fails too early.

The root cause is the *comment* header of  jquery-ui.css. Within this header exists the string "url(%22images%2Fui-icons_555555_256x240.png%22)".
I assume, it would be a good idea to either ignore comments or to be more tolerant or catch the exception and then evaluate STRICT_CSS_URL_REWRITING.
What do you think?

Regards,
Robert

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


Re: Tapestry w Scala

Posted by Alex Kotchnev <ak...@gmail.com>.
John,
  I thought I had more than this, but when I looked , all I had was
this module for this specific conversion for Lists (it does do the
job) . You can probably add this to your own module or use this module
and include it in your module.

object TapestryScalaModule {

  def contributeTypeCoercer(configuration:
Configuration[CoercionTuple[List[AnyRef], JList[AnyRef]]]) = {
    val coercion = new Coercion[List[AnyRef], JList[AnyRef]]() {
      def coerce(input: List[AnyRef]) = ListBuffer[AnyRef](input: _*)
    };

    configuration.add(new CoercionTuple[List[AnyRef],
JList[AnyRef]](classOf[List[AnyRef]], classOf[JList[AnyRef]],
coercion));
  }
}

Cheers - Alex K

On Mon, Dec 19, 2016 at 12:23 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Yep, as Alex said, you can solve this issue by contributing a coercion from
> Scala collection/list/etc to the corresponding Java type. There's an
> explanation with examples here:
> https://tapestry.apache.org/type-coercion.html.
>
> On Mon, Dec 19, 2016 at 11:59 AM, Alex Kotchnev <ak...@gmail.com> wrote:
>
>> John - I've been running Tapestry and Scala  for a few years now (e.g.
>> www.zadachite.com on AppEngine, and a few internal apps), and it's
>> been working pretty well. About the specific issue of the collection
>> conversions - it bugged me for a little while, and I'm pretty sure I
>> have a project somewhere on my workstation that contributes a few
>> coercions that do this conversion automatically (otherwise, you can
>> probably just use the scala.collections.JavaConversions to get this
>> done on each page). I'll see if I can hunt down what I do use and post
>> it somewhere for you to use.
>>
>> Cheers -
>>
>> On Fri, Dec 16, 2016 at 1:31 PM, Qbyte Consulting
>> <qb...@gmail.com> wrote:
>> > Thank you Thiago.
>> >
>> > I found that project and it has been very useful for creating my own.
>> >
>> > The only trouble I've had so far is delivering Scala collections back to
>> pages for loop components. I ended up using Java collections in the Scala
>> and that works fine.
>> >
>> > Sent from my iPhone
>> >
>> >> On 16 Dec 2016, at 18:11, Thiago H. de Paula Figueiredo <
>> thiagohp@gmail.com> wrote:
>> >>
>> >> On Fri, Dec 16, 2016 at 6:53 AM, Qbyte Consulting <
>> qbyteconsulting@gmail.com
>> >>> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >> Hi!
>> >>
>> >>
>> >>> Has anyone implemented a T5.4 site with Scala, or are there any
>> kickstart
>> >>> type Scala projects out there for T5.4 please? I'd like to see how it's
>> >>> done.
>> >>>
>> >>
>> >> Not me, but yes. Christian Köberl wrote a blog post about it,
>> >> https://derkoe.wordpress.com/2011/11/18/tapestry-in-scala/, and also a
>> demo
>> >> project, https://github.com/derkoe/tapestry-scala-demo. It uses
>> Tapestry
>> >> 5.3, but changing the pom.xml to use 5.4.1 should work.
>> >>
>> >> Tapestry works on class files, not Java sources, so it should just work
>> >> with whatever JVM language as long as it generates class files. It has
>> been
>> >> reported with working with Groovy as well, for example.
>> >>
>> >> --
>> >> Thiago
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> Thiago

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


Re: Tapestry w Scala

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Yep, as Alex said, you can solve this issue by contributing a coercion from
Scala collection/list/etc to the corresponding Java type. There's an
explanation with examples here:
https://tapestry.apache.org/type-coercion.html.

On Mon, Dec 19, 2016 at 11:59 AM, Alex Kotchnev <ak...@gmail.com> wrote:

> John - I've been running Tapestry and Scala  for a few years now (e.g.
> www.zadachite.com on AppEngine, and a few internal apps), and it's
> been working pretty well. About the specific issue of the collection
> conversions - it bugged me for a little while, and I'm pretty sure I
> have a project somewhere on my workstation that contributes a few
> coercions that do this conversion automatically (otherwise, you can
> probably just use the scala.collections.JavaConversions to get this
> done on each page). I'll see if I can hunt down what I do use and post
> it somewhere for you to use.
>
> Cheers -
>
> On Fri, Dec 16, 2016 at 1:31 PM, Qbyte Consulting
> <qb...@gmail.com> wrote:
> > Thank you Thiago.
> >
> > I found that project and it has been very useful for creating my own.
> >
> > The only trouble I've had so far is delivering Scala collections back to
> pages for loop components. I ended up using Java collections in the Scala
> and that works fine.
> >
> > Sent from my iPhone
> >
> >> On 16 Dec 2016, at 18:11, Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
> >>
> >> On Fri, Dec 16, 2016 at 6:53 AM, Qbyte Consulting <
> qbyteconsulting@gmail.com
> >>> wrote:
> >>
> >>> Hi,
> >>>
> >> Hi!
> >>
> >>
> >>> Has anyone implemented a T5.4 site with Scala, or are there any
> kickstart
> >>> type Scala projects out there for T5.4 please? I'd like to see how it's
> >>> done.
> >>>
> >>
> >> Not me, but yes. Christian Köberl wrote a blog post about it,
> >> https://derkoe.wordpress.com/2011/11/18/tapestry-in-scala/, and also a
> demo
> >> project, https://github.com/derkoe/tapestry-scala-demo. It uses
> Tapestry
> >> 5.3, but changing the pom.xml to use 5.4.1 should work.
> >>
> >> Tapestry works on class files, not Java sources, so it should just work
> >> with whatever JVM language as long as it generates class files. It has
> been
> >> reported with working with Groovy as well, for example.
> >>
> >> --
> >> Thiago
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Thiago

Re: Tapestry w Scala

Posted by Alex Kotchnev <ak...@gmail.com>.
John - I've been running Tapestry and Scala  for a few years now (e.g.
www.zadachite.com on AppEngine, and a few internal apps), and it's
been working pretty well. About the specific issue of the collection
conversions - it bugged me for a little while, and I'm pretty sure I
have a project somewhere on my workstation that contributes a few
coercions that do this conversion automatically (otherwise, you can
probably just use the scala.collections.JavaConversions to get this
done on each page). I'll see if I can hunt down what I do use and post
it somewhere for you to use.

Cheers -

On Fri, Dec 16, 2016 at 1:31 PM, Qbyte Consulting
<qb...@gmail.com> wrote:
> Thank you Thiago.
>
> I found that project and it has been very useful for creating my own.
>
> The only trouble I've had so far is delivering Scala collections back to pages for loop components. I ended up using Java collections in the Scala and that works fine.
>
> Sent from my iPhone
>
>> On 16 Dec 2016, at 18:11, Thiago H. de Paula Figueiredo <th...@gmail.com> wrote:
>>
>> On Fri, Dec 16, 2016 at 6:53 AM, Qbyte Consulting <qbyteconsulting@gmail.com
>>> wrote:
>>
>>> Hi,
>>>
>> Hi!
>>
>>
>>> Has anyone implemented a T5.4 site with Scala, or are there any kickstart
>>> type Scala projects out there for T5.4 please? I'd like to see how it's
>>> done.
>>>
>>
>> Not me, but yes. Christian Köberl wrote a blog post about it,
>> https://derkoe.wordpress.com/2011/11/18/tapestry-in-scala/, and also a demo
>> project, https://github.com/derkoe/tapestry-scala-demo. It uses Tapestry
>> 5.3, but changing the pom.xml to use 5.4.1 should work.
>>
>> Tapestry works on class files, not Java sources, so it should just work
>> with whatever JVM language as long as it generates class files. It has been
>> reported with working with Groovy as well, for example.
>>
>> --
>> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Tapestry w Scala

Posted by Qbyte Consulting <qb...@gmail.com>.
Thank you Thiago.

I found that project and it has been very useful for creating my own.

The only trouble I've had so far is delivering Scala collections back to pages for loop components. I ended up using Java collections in the Scala and that works fine.

Sent from my iPhone

> On 16 Dec 2016, at 18:11, Thiago H. de Paula Figueiredo <th...@gmail.com> wrote:
> 
> On Fri, Dec 16, 2016 at 6:53 AM, Qbyte Consulting <qbyteconsulting@gmail.com
>> wrote:
> 
>> Hi,
>> 
> Hi!
> 
> 
>> Has anyone implemented a T5.4 site with Scala, or are there any kickstart
>> type Scala projects out there for T5.4 please? I'd like to see how it's
>> done.
>> 
> 
> Not me, but yes. Christian Köberl wrote a blog post about it,
> https://derkoe.wordpress.com/2011/11/18/tapestry-in-scala/, and also a demo
> project, https://github.com/derkoe/tapestry-scala-demo. It uses Tapestry
> 5.3, but changing the pom.xml to use 5.4.1 should work.
> 
> Tapestry works on class files, not Java sources, so it should just work
> with whatever JVM language as long as it generates class files. It has been
> reported with working with Groovy as well, for example.
> 
> -- 
> Thiago

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


Re: Tapestry w Scala

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, Dec 16, 2016 at 6:53 AM, Qbyte Consulting <qbyteconsulting@gmail.com
> wrote:

> Hi,
>
Hi!


> Has anyone implemented a T5.4 site with Scala, or are there any kickstart
> type Scala projects out there for T5.4 please? I'd like to see how it's
> done.
>

Not me, but yes. Christian Köberl wrote a blog post about it,
https://derkoe.wordpress.com/2011/11/18/tapestry-in-scala/, and also a demo
project, https://github.com/derkoe/tapestry-scala-demo. It uses Tapestry
5.3, but changing the pom.xml to use 5.4.1 should work.

Tapestry works on class files, not Java sources, so it should just work
with whatever JVM language as long as it generates class files. It has been
reported with working with Groovy as well, for example.

-- 
Thiago