Unable to pass a variable parameter to jasper report - grails

So, I have created a simple CRUD app using groovy on grails and I want to use jasper reporting plugin to get some simple reports on the database. I have set up a simple G:select to pick from a drop down list, and hitting the PDF icon I am bringing back a blank page. gsp is below
<div id="page-body" role="main">
<p>Please select one of the following options</p>
<div>
<g:select optionKey="id"
optionValue="artist"
name="artist"
id="MusicCatalogue"
value="${artist}"
from="${multicatalogue.MusicCatalogue.list()}">
</g:select>
</div>
<div> <g:jasperReport jasper="report1" format="PDF" name="Music Catalogue" />
<input type="hidden" name="artist" value="${artist}" />
</div>
</div>
and then the jrxml looks like the below
<parameter name="artist" isForPrompting="true" class="java.lang.String">
<defaultValueExpression><![CDATA["<parameter error>"]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[SELECT *
FROM
MusicCatalogue where ARTIST = $P{artist}]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="ALBUM" class="java.lang.String"/>
<field name="ARTIST" class="java.lang.String"/>
<field name="TRACK" class="java.lang.String"/>
<group name="ARTIST">
ideas????

Try replace
<g:jasperReport jasper="report1" format="PDF" name="Music Catalogue" />
<input type="hidden" name="artist" value="${artist}" />
With
<g:jasperReport jasper="report1" format="PDF" name="Music Catalogue">
<input type="hidden" name="artist" value="${artist}" />
</g:jasperReport>
Also, make sure that ${artist} returns a string value, else the report will use the defaultValue of artist parameter that might ruin your query.

Related

typo3 double quotes in hash __trustedProperties 'The HMAC of the form could not be validated.'

thank you for your support.
I created a form with select options. The fields are filled with arrays provided with the settings variable.
The field in __trustedProperties quoted with the "-sign. This results in "{" as hash.
[__trustedProperties]" value="{"newRfichip":{"id":1,"status":1,"location":1,"personid":1}}2ec7e718db7f0844040e31baaa69a8452a650302" />
Normaly there should be & quot; instead the "-sign.
[__trustedProperties]" value="{& quot;newRfichip& quot;:{& quot;id& quot;:1,& quot;status& quot;:1,& quot;location& quot;:1,& quot;personid& quot;:1}}2ec7e718db7f0844040e31baaa69a8452a650302" />
I get always an exception 'The HMAC of the form could not be validated.'
I'm grateful for every hint, how i can solve this problem
FormFields.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<label for="id">
<f:translate key="tx_bbaorfichip_domain_model_rfichip.id" />
</label><br />
<f:form.textfield property="id" id="id" /><br />
<br\>
<f:debug>{_all}</f:debug>
<f:debug>{__trustedProperties}</f:debug>
<br\>
<label for="status">
<f:translate key="tx_bbaorfichip_domain_model_rfichip.status" />
</label><br />
<f:form.select property="status" id="status"
options="{settings.stati}"
value="4"
optionValueField="status"
optionLabelField="status" />
<br />
<label for="location">
<f:translate key="tx_bbaorfichip_domain_model_rfichip.location" />
</label><br />
<f:form.select property="location" id="location"
options="{settings.location}"
value="4"
optionValueField="location"
optionLabelField="location" />
<br />
<label for="personid">
<f:translate key="tx_bbaorfichip_domain_model_rfichip.personid" />
</label><br />
<f:form.select property="personid" id="personid"
options="{settings.personid}"
optionValueField="personid"
optionLabelField="personid" />
<br />
</html>

Change css/less based on user language or preferences language Odoo 10

Dears I am using Odoo 10. My requirement is bit different and I am not finding any such questions or answers on any forum. Actually I want to change the alignments of my text and icons based on user language or preferences selected language. I have created a custom module and I am able to use my custom styling. My xml file is as follows:
<odoo>
<data>
<template id="assets_backend" name="project_extend assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/project_extend/static/src/less/form_view_extra.less"/>
</xpath>
</template>
<record id="project.edit_project" model="ir.ui.view">
<field name="name">project.project.form</field>
<field name="model">project.project</field>
<field name="arch" type="xml">
<form string="Project">
<sheet string="Project">
<field name="analytic_account_id" invisible="1" required="0"/>
<div class="oe_button_box" name="button_box" groups="base.group_user">
<button class="oe_stat_button" name="attachment_tree_view" type="object" icon="fa-files-o">
<field string="Documents" name="doc_count" widget="statinfo"/>
</button>
<button class="oe_stat_button" type="action" attrs="{'invisible':[('use_tasks','=', False)]}"
name="%(project.act_project_project_2_project_task_all)d" icon="fa-tasks">
<field string="Tasks" name="task_count" widget="statinfo" options="{'label_field': 'label_tasks'}"/>
</button>
<button name="toggle_active" type="object"
confirm="(Un)archiving a project automatically (un)archives its tasks and issues. Do you want to proceed?"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name" placeholder="Project Name"/>
</h1>
<div name="options_active" class="oe_edit_only">
<div>
<field name="use_tasks" class="oe_inline"/>
<label for="use_tasks" class="oe_inline" string="Tasks"/>
<span attrs="{'invisible':[('use_tasks', '=', False)]}">as </span>
<field name="label_tasks" class="oe_inline oe_input_align" attrs="{'invisible': [('use_tasks', '=', False)]}"/>
</div>
</div>
</div>
<notebook>
<page name="settings" string="Settings">
<group>
<field name="user_id" string="Project Manager"
attrs="{'readonly':[('active','=',False)]}"/>
<field name="privacy_visibility" widget="radio"/>
<field name="partner_id" string="Customer"/>
</group>
<group name="misc">
<group string="Configuration" groups="base.group_no_one">
<field name="sequence" groups="base.group_no_one"/>
</group>
<group string="Time Scheduling" groups="base.group_no_one">
<field name="resource_calendar_id" groups="base.group_no_one"/>
</group>
</group>
</page>
<page name="emails" string="Emails" attrs="{'invisible': [('alias_domain', '=', False)]}">
<group name="group_alias">
<label for="alias_name" string="Email Alias"/>
<div name="alias_def">
<field name="alias_id" class="oe_read_only oe_inline"
string="Email Alias" required="0"/>
<div class="oe_edit_only oe_inline" name="edit_alias" style="display: inline;" >
<field name="alias_name" class="oe_inline"/>#<field name="alias_domain" class="oe_inline" readonly="1"/>
</div>
</div>
<label for="alias_model" string="Incoming Emails create" class="oe_edit_only"/>
<field name="alias_model" class="oe_inline oe_edit_only" nolabel="1"/>
<field name="alias_contact" class="oe_inline oe_edit_only"
string="Accept Emails From"/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" help="Follow this project to automatically track the events associated to tasks and issues of this project." groups="base.group_user"/>
</div>
</form>
</field>
</record>
<record id="hr_timesheet.project_invoice_form" model="ir.ui.view">
<field name="name">Inherit project form : Invoicing Data</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="priority">24</field>
<field name="arch" type="xml">
<button name="toggle_active" position="before">
<button class="oe_stat_button" name="%(hr_timesheet.act_hr_timesheet_line_by_project)d" type="action" icon="fa-calendar" string="Timesheets" attrs="{'invisible': [('allow_timesheets', '=', False)]}" style="text-align:right"/>
</button>
<field name="user_id" position="after">
<field name="subtask_project_id" groups="base.group_no_one" attrs="{'invisible': [('allow_timesheets', '=', False)]}"/>
</field>
<xpath expr="//div[#name='options_active']" position="inside">
<div>
<field name="allow_timesheets" class="oe_inline" string="Allow timesheets"/>
<label for="allow_timesheets"/>
</div>
</xpath>
</field>
</record>
</data>
</odoo>
As you can see in the beginning I am including stylesheet which is working perfectly. Now I want to compare the user/preferences language. If it is arabic language then stylesheet should be included else if user/preference language is english the the stylesheet should not be included so that the default alignment in odoo should come in effect. Any help is really appreciated.

Why don't datetime fields with ISO 8601 values work in iOS webkit browsers?

Why doesn't the following datetime field display the current value in Safari or PhoneGap in iOS?
<input type="datetime" value="2013-05-22T10:00:00+0000" />
It displays a blank value.
In iOS, datetime input fields only work with values in UTC, and only with the Zulu timezone designation. Neither local times nor UTC times with a +0000 offset are acceptable. The inclusion of milliseconds in the time are acceptable.
The following values work:
<input type="datetime" value="2013-05-22T10:00:00Z" />
<input type="datetime" value="2013-05-22T10:00:00.000Z" />
None of these work:
<input type="datetime" value="2013-05-22T10:00:00+0000" />
<input type="datetime" value="2013-05-22T10:00:00.000+0000" />
<input type="datetime" value="2013-05-22T10:00:00-0700" />
<input type="datetime" value="2013-05-22T10:00:00.000-0700" />
<input type="datetime" value="2013-05-22T10:00:00" />
<input type="datetime" value="2013-05-22T10:00:00.000" />

Grails Jasper hidden parameter

I am creating a basic report wherein I could pass the domain model passed by the controller to the view and use that instance as a parameter for the report.
Here the part of the <g:jasperReport> in the view[.gsp]
Note: ${user} is an instance of User inside the domain classes having those string properties: lastName, firstName, middleName
<g:jasperReport
jasper="reportByUser"
format="pdf, html">
<input type="hidden" name="u_lastName" value="${user.lastName}" />
<input type="hidden" name="u_firstName" value="${user.firstName}" />
<input type="hidden" name="u_middleName" value="${user.middleName}" />
</g:jasperReport>
Here the part of the xml code inside the reportByUser.jrxml
<parameter name="user_lastName" class="java.lang.String" />
<parameter name="user_firstName" class="java.lang.String" />
<parameter name="user_middleName" class="java.lang.String" />
The problem is when I run the report on the grails, either format return a blank page.
In:
<g:jasperReport
jasper="reportByUser"
format="pdf, html">
<input type="hidden" name="u_lastName" value="${user.lastName}" />
<input type="hidden" name="u_firstName" value="${user.firstName}" />
<input type="hidden" name="u_middleName" value="${user.middleName}" />
</g:jasperReport>
You are passing: name="u_lastName"
But in the jasper file is specting: name="user_lastName"
Check it...

Struts2: Hidden field and anchor tag <s:a> values In Action Class

I am working on a struts2 application. In my jsp page I have 2-3 anchor tag and 2-3 hidden fields like
<s:a href="#">File 1</s:a>
<s:a href="#">File 2</s:a>
<s:a href="#">File 3</s:a>
and
<s:hidden name=" hidden1" />
<s:hidden name=" hidden2" />
<s:hidden name=" hidden3" />
Now please let me know, In my action class how can I get value of all the hidden fields and anchor tag which was clicked.
I had tried following
<s:a href="#" action=”someAction”>File 1</s:a>
Its working but didn’t transfer value of hidden fileds.
Also
<s:a href="#" name=”File1” onclick=”submit”>File 1</s:a>
But no gain.
Looking for your reply.
Like Boris said, you need to put the hidden fields inside a form, and submit that form, OR you can add them as URL parameters to your links. The best method is probably using a form with POST so the hidden fields aren't on your browser's location bar.
Here's an example
<s:form id="myform" name="myform" action="someAction" method="POST">
<s:hidden name=" hidden1" value="first value"/>
<s:hidden name=" hidden2" value="second value"/>
<s:hidden name=" hidden3" value="third value"/>
Submit with link
<s:submit value="%{'Submit with button'}" />
</s:form>
Since this really has nothing to do with struts2, here's an example with pure HTML:
<form id="myform" name="myform" action="someAction.action" method="POST">
<input type="hidden" name=" hidden1" value="first value"/>
<input type="hidden" name=" hidden2" value="second value"/>
<input type="hidden" name=" hidden3" value="third value"/>
Submit with a link
<br/>
<input type="submit" value="Submit with a button"/>
</form>

Resources