pb with <g:if>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

pb with <g:if>

Dierk König
Hi,

I have this snippet in my gsp.

<g:if test="session?.user">
    ${tutorialEntry.visitedBy(session.user)}
    <g:if test="tutorialEntry.visitedBy(session.user)">
        <span class="button"><g:actionSubmit value="Visited"/></span>
    </g:if>
</g:if>

While it prints 'true/false' correctly, indicating wether
the user has marked the current tutorialEntry as 'visited', it
fails to suppress the button display when 'false'.
Instead the button is always rendered.

Any idea?

Mittie
Reply | Threaded
Open this post in threaded view
|

RE: pb with <g:if>

Dierk König
seems to be that <g:if> doesn't work inside <g:form>

<g:form controller="tutorialEntry">
    <g:if test="false">
        <span class="button"><g:actionSubmit value="Visited"/></span>
    </g:if>
</g:form>

renders the button

Mittie

> -----Original Message-----
> From: Dierk Koenig [mailto:[hidden email]]
> Sent: Freitag, 10. März 2006 11:52
> To: GrailsDev
> Subject: [grails-dev] pb with <g:if>
>
>
> Hi,
>
> I have this snippet in my gsp.
>
> <g:if test="session?.user">
>     ${tutorialEntry.visitedBy(session.user)}
>     <g:if test="tutorialEntry.visitedBy(session.user)">
>         <span class="button"><g:actionSubmit value="Visited"/></span>
>     </g:if>
> </g:if>
>
> While it prints 'true/false' correctly, indicating wether
> the user has marked the current tutorialEntry as 'visited', it
> fails to suppress the button display when 'false'.
> Instead the button is always rendered.
>
> Any idea?
>
> Mittie

Reply | Threaded
Open this post in threaded view
|

Re: pb with <g:if>

graemer
On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> seems to be that <g:if> doesn't work inside <g:form>
>
> <g:form controller="tutorialEntry">
>     <g:if test="false">
>         <span class="button"><g:actionSubmit value="Visited"/></span>
>     </g:if>
> </g:form>
>
> renders the button
Can you file an issue.. some hints as to why it doesn't work can be
found by appending ?showSource=true on the end of the url

Graeme

>
> Mittie
>
> > -----Original Message-----
> > From: Dierk Koenig [mailto:[hidden email]]
> > Sent: Freitag, 10. März 2006 11:52
> > To: GrailsDev
> > Subject: [grails-dev] pb with <g:if>
> >
> >
> > Hi,
> >
> > I have this snippet in my gsp.
> >
> > <g:if test="session?.user">
> >     ${tutorialEntry.visitedBy(session.user)}
> >     <g:if test="tutorialEntry.visitedBy(session.user)">
> >         <span class="button"><g:actionSubmit value="Visited"/></span>
> >     </g:if>
> > </g:if>
> >
> > While it prints 'true/false' correctly, indicating wether
> > the user has marked the current tutorialEntry as 'visited', it
> > fails to suppress the button display when 'false'.
> > Instead the button is always rendered.
> >
> > Any idea?
> >
> > Mittie
>
>
Reply | Threaded
Open this post in threaded view
|

RE: pb with <g:if>

Dierk König
good hint :-)

it results in

if("false")

;-)

So I guess I should have written
<g:if test="${false}">

Is that the intended usage?

thanks for the help
Mittie


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Freitag, 10. März 2006 15:15
> To: [hidden email]
> Subject: Re: [grails-dev] pb with <g:if>
>
>
> On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> > seems to be that <g:if> doesn't work inside <g:form>
> >
> > <g:form controller="tutorialEntry">
> >     <g:if test="false">
> >         <span class="button"><g:actionSubmit value="Visited"/></span>
> >     </g:if>
> > </g:form>
> >
> > renders the button
> Can you file an issue.. some hints as to why it doesn't work can be
> found by appending ?showSource=true on the end of the url
>
> Graeme
>
> >
> > Mittie
> >
> > > -----Original Message-----
> > > From: Dierk Koenig [mailto:[hidden email]]
> > > Sent: Freitag, 10. März 2006 11:52
> > > To: GrailsDev
> > > Subject: [grails-dev] pb with <g:if>
> > >
> > >
> > > Hi,
> > >
> > > I have this snippet in my gsp.
> > >
> > > <g:if test="session?.user">
> > >     ${tutorialEntry.visitedBy(session.user)}
> > >     <g:if test="tutorialEntry.visitedBy(session.user)">
> > >         <span class="button"><g:actionSubmit value="Visited"/></span>
> > >     </g:if>
> > > </g:if>
> > >
> > > While it prints 'true/false' correctly, indicating wether
> > > the user has marked the current tutorialEntry as 'visited', it
> > > fails to suppress the button display when 'false'.
> > > Instead the button is always rendered.
> > >
> > > Any idea?
> > >
> > > Mittie
> >
> >

Reply | Threaded
Open this post in threaded view
|

Re: pb with <g:if>

graemer
On 10/03/06, Dierk Koenig <[hidden email]> wrote:

> good hint :-)
>
> it results in
>
> if("false")
>
> ;-)
>
> So I guess I should have written
> <g:if test="${false}">
>
> Is that the intended usage?
It was a tricky decision, basically there was 2 options, i could either have:

a) Forced the user to put single quotes around values they want to be
strings like:

<g:if test="'value'"> // not the single quotes within the doubles,
difficult to spot i know :)

</g:if>

or
b) Force the user to put ${} around things regarded to be
'expressions' and everything else is a string.

This is in general the approach JSP takes with expressions being
insides ${} so i followed this route. Funnily enough, webwork's tags
actually take approach a)

Cheers
Graeme

>
> thanks for the help
> Mittie
>
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]On Behalf
> > Of Graeme Rocher
> > Sent: Freitag, 10. März 2006 15:15
> > To: [hidden email]
> > Subject: Re: [grails-dev] pb with <g:if>
> >
> >
> > On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> > > seems to be that <g:if> doesn't work inside <g:form>
> > >
> > > <g:form controller="tutorialEntry">
> > >     <g:if test="false">
> > >         <span class="button"><g:actionSubmit value="Visited"/></span>
> > >     </g:if>
> > > </g:form>
> > >
> > > renders the button
> > Can you file an issue.. some hints as to why it doesn't work can be
> > found by appending ?showSource=true on the end of the url
> >
> > Graeme
> >
> > >
> > > Mittie
> > >
> > > > -----Original Message-----
> > > > From: Dierk Koenig [mailto:[hidden email]]
> > > > Sent: Freitag, 10. März 2006 11:52
> > > > To: GrailsDev
> > > > Subject: [grails-dev] pb with <g:if>
> > > >
> > > >
> > > > Hi,
> > > >
> > > > I have this snippet in my gsp.
> > > >
> > > > <g:if test="session?.user">
> > > >     ${tutorialEntry.visitedBy(session.user)}
> > > >     <g:if test="tutorialEntry.visitedBy(session.user)">
> > > >         <span class="button"><g:actionSubmit value="Visited"/></span>
> > > >     </g:if>
> > > > </g:if>
> > > >
> > > > While it prints 'true/false' correctly, indicating wether
> > > > the user has marked the current tutorialEntry as 'visited', it
> > > > fails to suppress the button display when 'false'.
> > > > Instead the button is always rendered.
> > > >
> > > > Any idea?
> > > >
> > > > Mittie
> > >
> > >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: pb with <g:if>

graemer
On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> tricky choice :-)
>
> but what would exactly be the use for testing 'value' via
>  <g:if test="value">
> ?
> Isn't 'test' a special case where only boolean expressions make sense
> anyway?
Possibly, but then it would be inconsistent wouldn't it? How would you
know when to use ${} and when not to?

Graeme

>
> cheers
> Mittie
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]On Behalf
> > Of Graeme Rocher
> > Sent: Freitag, 10. März 2006 15:38
> > To: Dierk Koenig
> > Cc: [hidden email]
> > Subject: Re: [grails-dev] pb with <g:if>
> >
> >
> > On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> > > good hint :-)
> > >
> > > it results in
> > >
> > > if("false")
> > >
> > > ;-)
> > >
> > > So I guess I should have written
> > > <g:if test="${false}">
> > >
> > > Is that the intended usage?
> > It was a tricky decision, basically there was 2 options, i could
> > either have:
> >
> > a) Forced the user to put single quotes around values they want to be
> > strings like:
> >
> > <g:if test="'value'"> // not the single quotes within the doubles,
> > difficult to spot i know :)
> >
> > </g:if>
> >
> > or
> > b) Force the user to put ${} around things regarded to be
> > 'expressions' and everything else is a string.
> >
> > This is in general the approach JSP takes with expressions being
> > insides ${} so i followed this route. Funnily enough, webwork's tags
> > actually take approach a)
> >
> > Cheers
> > Graeme
> >
> > >
> > > thanks for the help
> > > Mittie
> > >
> > >
> > > > -----Original Message-----
> > > > From: [hidden email]
> [mailto:[hidden email]]On Behalf
> > > Of Graeme Rocher
> > > Sent: Freitag, 10. März 2006 15:15
> > > To: [hidden email]
> > > Subject: Re: [grails-dev] pb with <g:if>
> > >
> > >
> > > On 10/03/06, Dierk Koenig <[hidden email]> wrote:
> > > > seems to be that <g:if> doesn't work inside <g:form>
> > > >
> > > > <g:form controller="tutorialEntry">
> > > >     <g:if test="false">
> > > >         <span class="button"><g:actionSubmit value="Visited"/></span>
> > > >     </g:if>
> > > > </g:form>
> > > >
> > > > renders the button
> > > Can you file an issue.. some hints as to why it doesn't work can be
> > > found by appending ?showSource=true on the end of the url
> > >
> > > Graeme
> > >
> > > >
> > > > Mittie
> > > >
> > > > > -----Original Message-----
> > > > > From: Dierk Koenig [mailto:[hidden email]]
> > > > > Sent: Freitag, 10. März 2006 11:52
> > > > > To: GrailsDev
> > > > > Subject: [grails-dev] pb with <g:if>
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I have this snippet in my gsp.
> > > > >
> > > > > <g:if test="session?.user">
> > > > >     ${tutorialEntry.visitedBy(session.user)}
> > > > >     <g:if test="tutorialEntry.visitedBy(session.user)">
> > > > >         <span class="button"><g:actionSubmit
> value="Visited"/></span>
> > > > >     </g:if>
> > > > > </g:if>
> > > > >
> > > > > While it prints 'true/false' correctly, indicating wether
> > > > > the user has marked the current tutorialEntry as 'visited', it
> > > > > fails to suppress the button display when 'false'.
> > > > > Instead the button is always rendered.
> > > > >
> > > > > Any idea?
> > > > >
> > > > > Mittie
> > > >
> > > >
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

RE: pb with <g:if>

Dierk König
> > Isn't 'test' a special case where only boolean expressions make sense
> > anyway?
> Possibly, but then it would be inconsistent wouldn't it? How would you
> know when to use ${} and when not to?

In the special case of 'test' we can look whether it contains ${}.
If not:
- throw an error
- log a warning
- surround with ${}
or something.

The current behaviour of silently ignoring it will lead to
much work on the mailinglist ;-)

Mittie