Liferay portlet with freemarker and spring - liferay-6

I am developing simple portlet for liferay portal(v6.2) using spring portlet mvc(v3.2.9) with FreeMarker template engine(v2.3.14).
I use portlet and aui taglibs to create pages
<#assign portlet=JspTaglibs["http://java.sun.com/portlet"]>
<#assign aui=JspTaglibs["http://liferay.com/tld/aui"]>
Those tags works in most cases but I have problem with following code
<#aui.form action="${editPreferencesUrl}">
<#aui.model-context bean="${myBean}" />
<#aui.input name="name" />
<#aui.input name="surname" />
</#aui.form>
I get following exception
javax.portlet.PortletException: org.springframework.web.util.NestedServletException: View rendering failed; nested exception is freemarker.core.NonNumericalException: Error on line 8, column 11 in preferences.ftl
Expression aui.model is not numerical
Expression context is not numerical
I was following this tutorial http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Alloy+UI+Forms+(aui)/pop_up?_36_version=1.9
The problem is #aui.model-context definitely. How to use this tag in free marker?

Like <#aui['model-context'] bean=...>. (Because, foo.bar is equivalent with foo['bar'], and the thing after # is just a generic FTL expression.)
BTW, are those "${expression}"-s necessary? Do you have to convert to string there? Because otherwise you should just write action=editPreferencesUrl and such.

Related

JSF nested components with forms

Is it considered correct to have a composite component (compA) that holds a form, when compA can itself be contained in another form (in the using page)?
<!-- composite -->
<cc:implementation>
<h:form id="innerForm">
... composite stuff
</h:form>
</cc:implementation>
<!-- using page/component -->
<h:form id="outerForm">
<util:compA ... />
</h:form>
When trying to remove nested forms, any ajax call in the composite will submit the whole form, and as has some values may not yet be filled, validation fails.
Is there any best-practice approach to this?
Nested forms are always a bad idea and will result in invalid HTML output.
A Composite Component itself is a Naming Container so it should not be a problem to process only the CC or even some parts of it.
To prevent the whole form from being even submitted I would suggest PrimeFaces AJAX calls with partialSubmit="true". See here for reference.
If there are still problems with your AJAX calls you habe to provide the related code of your CC.

Can I use css3 in my Birt Report?

I want to use CSS3 in my Birt Report. But its showing the problem of CSS2.
A BIRT exception occurred.
Plug-in Provider:Eclipse BIRT Project
Plug-in Name:BIRT Model
Plug-in ID:org.eclipse.birt.report.model
Version:4.3.1.v201308301349
Error Code:Error.StyleSheetException.SYNTAX_ERROR
Error Message:There are some syntax errors inconsistent with CSS2.
So can anyone help me like how can I use my CSS3 file for my report. Is there any plugin or some steps then please let me know.
You can use css3 in html format only, by including the css file at viewtime. But it would be ignored by pdf & other formats.
For example, we are going to include this jquery-mobile theme at viewtime:
//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.2/jquery.mobile.min.css
To test this example, add a BIRT text element in the report, set type to HTML and include fragment below:
<button data-icon="star" data-theme="a" data-form="ui-btn-up-a" class=" ui-btn ui-btn-a ui-icon-star ui-btn-icon-left ui-shadow ui-corner-all">Button</button>
Run the report, you will see a great jqueryMobile-like css3 button!
You can also load the external files in the clientScripts of the report using head.js. For example, in a report's clientScripts > clientInitialize event, add:
head.js("http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js",
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css");
In the XML source, this appears as the last line in the following code.
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.4.0.v20150206-1039 Build <4.2.3.v20150206-1039></property>
<property name="units">in</property>
<method name="clientInitialize"><![CDATA[head.js("http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js", "http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css");
]]></method>

generate tag xml in JAVA

How i generate tag XML like this in java to hit HTTP POS SOA ?
Parameter:
<opNameA>
<Header>
<code11>A34</code11>
<code12>POS</code12>
</Header>
<opname>
<code1>1234</code1>
<code2>123456</code2>
<code3>abc123</code3>
<code4>xyz123</code4>
<code5>78689332</code5>
<code6>50000</code6>
<code7>2013-11-11 10:15</code7>
</opname>
</opNameA>
You could use either DOM or SAX parsing for generating xml in java. Please follow the below links for the basics.
http://www.w3schools.com/dom/
http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/

Customised Error Message for default DateValidator in Wicket

I'm using DateValidator class to validate the date entered by user. I'm getting generic error message for this. Can I customise the error message without creating a separate Validator class.
Yes, for example if you have the following kind of page.
MyPage.html
<wicket:page>
<form wicket:id="form">
<input type="text" wicket:id="startDate" />
<input type="text" wicket:id="endDate" />
</form>
</wicket:page>
Then you add next to your java class a properties file named MyPage.properties in which you add the following entries.
MyPage.properties
form.startDate.DateValidator.minimum=<message for minimum startDate>
form.startDate.DateValidator.maximum=<message for maximum startDate>
form.endDate.DateValidator.minimum=<message for minimum endDate>
form.endDate.DateValidator.maximum=<message for maximum endDate>
You can use variables like ${input} or ${label} to be substituted in the feedback messages.
A good place to start is in the Wiki of Apache Wicket at https://cwiki.apache.org/confluence/x/N1IB
Looking at the API Docs for DateValidator i can see that based on the condition that failed wicket used different error keys ..like : DateValidator.range, DateValidator.minimum, DateValidator.maximum. You can use this keys and create your custom error messages for this situations.

jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'

I meet the following problem
I am using AlloyUI to implement a portlet in Liferay
with the following code
<liferay-ui:search-container-row
className="com.handysoft.tp.model.TradingCategory"
keyProperty="cId"
modelVar="category">
<liferay-ui:search-container-column-text
name="category-name"
value="<%= category.getCName() %>" />
<liferay-ui:search-container-column-jsp
path="/admin/action.jsp"
align="right" />
</liferay-ui:search-container-row>
Portlet still works but I meet the following error
jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'
If I change one small section to
<liferay-ui:search-container-column-text
name="category-name"
property="cName" />
The error happen in with both cName and cId. Nothing is appear, could u help me to solve this
FeinesFabi is right. It seems that Liferay Search container doesn't take the property names which has more than 1 capital letters in it.
For ex. if a property is tClassId then it won't work but tclassId will work fine.
I've had the same problem.
Renaming the primary key from gID to glossarId an re-running the service builder fixed it for me. I don't understand why, though.