Grails remoteLink handling error codes - grails

I'm on grails 1.3.6 and I see the following behavior.
<g:javascript library="prototype" />
...
<g:remoteLink action="punch" id="${personInstance.id}" update="damage_${personInstance.id}" on401="alert('foo!');">
generates:
<a on401="alert('foo!');" onclick="new Ajax.Updater('damage_5','/blah/person/punch/5',{asynchronous:true,evalScripts:true});return false;" href="/blah/person/punch/5"></a>
"on401" isn't a supported event attribute for an anchor tag, so is this a bug in grails?

On 1.3.5 for me, it just lost on401 attribute.
Looks like bug GRAILS-7062.

Related

Build-in Grails tags do not work

During grails application upgrade from 1.3.8 to 2.3.9 I run into the problem that grails build-in tags are ignored.
For example lets say that GSP page has two tags:
<g:if test="${true}">OK</g:if>
<g:hiddenField name="test" />
then the result of execution will be:
OK
<g:hiddenField name="test" />
but expected result is :
OK
<input type="hidden" name="test" />
Basically tags from grails-web-2.3.9.jar are working fine but from grails-plugin-gsp-2.3.9.jar are completely ignored.
Any clue why this happens is appreciated. Thank you.
UPDATE:
I found that while executing TagLibraryLookup.afterPropertiesSet() method grailsApplication object is null, so the tag lib is not registered. Now it is not clear why it is null...
Solotion:
The problem was that within static constraints = { } of domain object it was a call of
ApplicationHolder?.getApplication().getMainContext()?.getBean(serviceName) method. It prevented the application from initialization of all required spring/grails beans by changing initialization sequence/flow.
You're missing some double-quotes here:
<g:if test=${true}>OK</g:if>
<g:hiddenField name="test" />
If you add them:
<g:if test="${true}">OK</g:if>
<g:hiddenField name="test" />
Does that help? Also, check for any changes to the default encoding that was made in Config.groovy after you upgraded.

How to invoke a JSF composite within composite:implementation?

How could you invoke a JSF2 composite (widget) within anothers composite's implementation tag?
When I do so, I get the following error: /resources/widgets/tileContainer.xhtml #25,45 <mywidgets:tileContainer> Tag Library supports namespace: http://java.sun.com/jsf/composite/widgets, but no tag was defined for name: tileContainer
The code snippet is:
<composite:interface name="tileContainer">
<composite:attribute name="pubCategoryId" type="java.lang.Long" required="true" />
</composite:interface>
<composite:implementation>
<div class="tileContainer">
<ui:repeat value="#{pubController.getPubsByCategory(cc.attrs.pubCategoryId)}" var="pub">
#{pub.title}
<mywidgets:tileContainer title="Private">
<mywidgets:tileSmallPictureTitle
title="Bulk Dispatch Lapse stressed with application protocols">
</mywidgets:tileSmallPictureTitle>
</mywidgets:tileContainer>
</ui:repeat>
</div>
</composite:implementation>
Any other design recommendations on how to handle this?
Thank you for sharing your thoughts.
This is recognizable as Mojarra issue 2437 which was fixed in Mojarra 2.1.10 (released 25 july 2012). It look like you're using a rather outdated Mojarra version. It's currently already at 2.1.25 (2.2.x is even already out, but I wouldn't recommend switching to 2.2 right now, let them fix all childhood diseases first).
Okay, I moved the namespace declaration of my composite directory from the <html xmlns... tag down to the <composite:implementation> tag.
So the composite looks like this:
<composite:implementation xmlns:mywidgets="http://java.sun.com/jsf/composite/widgets">
Otherwise, the namespaces of the parent and child composite will resolve wrongly.

<c:catch> does not work with <fmt:parseNumber> JSTL 1.2

I'm implementing a simple JSP page using JSTL 1.2 (Apache Taglibs). The page does the following:
<c:catch var="error">
<fmt:parseNumber var="parsedNum" value="${param.num}" />
</c:catch>
The HTML input element looks like this:
<input type="text" name="num" size="3"/>
I'm aware that the input "12a" is permitted due to the way the parsing mechanism works. Nevertheless, I would like to catch completely wrong input, e.g., "aaa". Unfortunately, the thrown exception is not managed by <c:catch>, resulting in Tomcat 7 showing the whole stack trace.
Any advice? Thanks.
Please post a testable page for us. For example, the following page works fine for me.
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:catch var="error">
<fmt:parseNumber var="parsedNum" value="aaa" />
</c:catch>
${parsedNum}
${error}

JSF 2.0 Warning about a component not surronded by an h:form tag [duplicate]

I am getting the following error on my Facelet page, which simply consists of an IceFaces form with two fields and two buttons:
The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>
Here is the form:
<ice:form id="form1" partialSubmit="false">
<ice:panelLayout id="panelLayout3">
<ice:graphicImage id="graphicImage1" url="/resources/images/LoginImage.jpg" width="560" />
<ice:outputLabel for="j_username" id="outputLabel1" value="Username:"/>
<ice:outputLabel for="j_password" id="outputLabel2" value="Password:"/>
<ice:inputText binding="#{login.username}" id="j_username" required="true" />
<ice:inputSecret binding="#{login.password}" id="j_password" required="true" />
<ice:commandButton actionListener="#{login.login}" id="loginBtn" value="Login"/>
<ice:commandButton action="#{login.reset}" id="resetBtn" value="Reset"/>
<ice:outputText id="errorMessage" />
<ice:message errorClass="errorMessage" for="j_username" fatalClass="fatalMessage" id="messages1" infoClass="infoMessage" showSummary="false" warnClass="warnMessage"/>
</ice:panelLayout>
</ice:form>
How is this caused and how can I solve it?
This is not an error. This is a warning. The code looks fine, all input components are inside a form, it seems that it should run and work fine. If it indeed works fine, just ignore the warning. This warning is displayed only when the context parameter javax.faces.PROJECT_STAGE is set to Development anyway .
As to the false warning message itself, this check was introduced in Mojarra 2.1.1 as per issue 1663. However, as per issue 2147 it turns out to have some bugs and is been further improved in Mojarra 2.1.3. I'd imagine that the false warning is in your particular case caused by having an <ice:panelLayout> between the form and the input elements.
If you aren't on Mojarra 2.1.3 yet, you may want to consider upgrading to see if it removes the false warning message.

grails-ui plugin autocomplete component error

I'm programming a page that uses the grails-ui plugin "autocomplete" feature. It doesn't work and the error console shows the error "YAHOO is not defined"; searching the web I tried the following:
Install the yui2 ad 3 plugins
Uninstall the grails-ui plugin
reinstall the grails-ui plugin
With no luck.
Any ideas ? I'm using grails 1.2
Here's my gsp:
<%# page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<gui:resources components="autocomplete" />
<title>Sample title</title>
</head>
<body>
<h1>Sample line</h1>
<g:form action="autoespec" id="id1">
<gui:autoComplete
id="spec"
name="spec"
resultName="result"
labelField="name"
idField="id"
controller="inscripcion"
action="autoespec"
/>
<input type="text" name="query">
<input type="submit">
</g:form>
</body>
</html>
Added an input to check that the controller worked (it does).
You have to add a special class to your body.
<body class="yui-skin-sam">
...
It appears that you've got the tag namespaces wrong. Assuming you're using the latest richui plugin from http://www.grails.org/RichUI+Plugin and installed it using grails install-plugin richui you need the following tags:
<resource:autoComplete skin="default"/>
in the page head and for the autocomplete box itself:
<richui:autoComplete ... />
I also notice that the attributes you're using for the riuchui:autocomplete element are not in the documentation so you might want to give it another read: http://www.grails.org/RichUI+Plugin#AutoComplete
HTH

Resources