Archive | 4:22 pm

For Showing a comboo by static value in Grails

17 Jan

Technique No-1:

If Value String (Key with cotation):

 <g:select id=”active” name=”active”  from=”${[‘Enabled’,’Disabled’]}”  keys=”${[‘A’,’B’]}” value=”${afmCalendarInstance?.calendarType}” /> 

If Value Integer (Key without cotation):

 <g:select id=”active” name=”active”  from=”${[‘Enabled’,’Disabled’]}”  keys=”${[1,2]}”  value=”${afmCalendarInstance?.calendarType}” />

Technique No-2 :

# In domain Class:

class Sponsorship {

String contributionType

static constraints = {
contributionType(inList:[“Other” , “Venue” , “A/V” , “Promotion” , “Cash”,”Maruf” ])
}

}
# In .gsp page

<g:fieldValue bean=”${tekEventInstance}” field=”venue”/>

It will show as comboo with value….
—————————————————————————————————————-

Technique No-3 :

–           ‘belongsTo’ is used to show that another class is the owning side of a relationship. It is
used for one-to-many and many-to-many relationships.

class Parent {

static hasMany = [children:Child]

}

class Child {

Parent parent

static belongsTo = Parent

}
========================Example====================
class Message {

String subject
TekEvent event

static constraints = {
subject(blank:false)
}

static belongsTo = TekEvent
}

class TekEvent {
String city
String name
String description
static hasMany = [ messages:Message]

static constraints = {
name()
city()
description(maxSize : 5000)
messages(nullable : true)
}

} 

# ‘toString()’ 

class Message {
String subject
String content
TekEvent event

String toString(){ subject }

static constraints = {
subject(blank:false)
content(blank:false, maxSize:2000)
}

static belongsTo = TekEvent
}

# class TekEvent {
String city
String name
String description

static hasMany = [ messages:Message]
static constraints = {
name()
city()
description(maxSize : 5000)
messages(nullable : true)
}

}

# <g:each in=”${tekEventInstance.volunteers}” var=”v”>

<g:link controller=”tekUser”     action=”show”   id=”${v.id}”>
${v?.
encodeAsHTML()}
</g:link>
</span>
</g:each>

NB.- For writing  the line  “String toString(){ subject }” in class Message  in .gsp page result will be against “${v?.encodeAsHTML()}” the line will be the value of  “subject”  column.
If 
the line  “String toString(){ subject }” in class Message  in .gsp page result will be against “${v?.encodeAsHTML()}” the line will be “tekdays.Message : 1” i.e.”parentClassName.childClassName:childClassId(PK)value”

//

How to show a Style on a element conditionally in iReport?

17 Jan

a) Create a style –
<style name=”alternateStyle” forecolor=”#000000″ fontName=”Arial”>

<conditionalStyle>
<conditionExpression>
                                                <![CDATA[new Boolean($F{IS_BOLD}== ‘Y’)]]>
</conditionExpression>
<style forecolor=”#000000″ isBold=”true”/>
</conditionalStyle>
</style>

Or , For more than one condition

<style name=”alternateStyle” forecolor=”#000000″ fontName=”Arial”>

<conditionalStyle>
<conditionExpression>
                                                <![CDATA[new Boolean($F{IS_BOLD}== ‘Y’)]]>
</conditionExpression>
<style forecolor=”#000000″ isBold=”true”/>
</conditionalStyle>

<conditionalStyle>
<conditionExpression>
<![CDATA[new Boolean($F{CASH_FLOW_HEAD}==null)]]>
</conditionExpression>
<style forecolor=”#FF0000″ isBold=”true”/>
</conditionalStyle>

</style>

b) put the style in the desired “textField”-
<textField isBlankWhenNull=”true”>
<reportElement uuid=”47d8dea6-067b-4ff9-b846-f73c1fdb7abe” style=”alternateStyle” x=”0″ y=”0″ width=”355″ height=”20″/>

<box>
                                                <pen lineWidth=”0.5″/>
<topPen lineWidth=”0.0″/>
<leftPen lineWidth=”0.5″/>
<bottomPen lineWidth=”0.0″/>
<rightPen lineWidth=”0.0″/>
</box>

<textElement/>
                                <textFieldExpression>
                                   <![CDATA[($F{CASH_FLOW_HEAD}==null?” “:$F{CASH_FLOW_HEAD})+($F{HEAD_2}==null?””:$F{HEAD_2})]]>
                      </textFieldExpression>
</textField>

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-49304906-2’, ‘wordpress.com’);
ga(‘send’, ‘pageview’);

Some Useful Information For iReport…

17 Jan

How to fixed date format in a string date field  :

-“From “+new java.text.SimpleDateFormat(“dd/MM/yyyy”).format($P{P_FROM_DATE})+” to “+new java.text.SimpleDateFormat(“dd/MM/yyyy”).format($P{P_TO_DATE})

How to Check Negative value and replace with ‘()’ :
$F{DR_BALANCE}<0?”(“+(new DecimalFormat(‘#,##0.000’).format($F{DR_BALANCE}*-1))+”)”:(new DecimalFormat(‘#,##0.000’).format($F{DR_BALANCE}))

Ternary operator Multiple conditions:

$F{PARTICULARS}==”Income-Academic”?”Total Income (Academic)”:

($F{PARTICULARS}==”Expenditure-Academic”?”Total Expenses (Academic)”:

($F{PARTICULARS}==”Expenditure- Non Academic”?”Total Non Academic Expenses”:””))

 

( iReport )Ternary operator Single conditions:

$F{PARTICULARS}==”Income-Academic”?”Total Income (Academic)”:”A”
How to show a attribute or element conditionally?
in properties panel of the element => change “Print When Expression” value only Boolean value like that->                $F{IS_SUBSIDIARY}==0?true:false

How to Add Format in a number in a String?

“Taka “+(new DecimalFormat(‘#,##0.00’).format($F{PAYABLE_AMOUNT}))

SQL: Get Value IF A Parameter is not PASSES

SELECT STUDENT_ID,A.CREDIT_DATE,CREDIT_AMOUNT,RECONCILE_TYPE

FROM UPLOAD_STD_BANK_STATEMENT A

WHERE CREDIT_DATE BETWEEN $P{FDATE} AND $P{TDATE}

AND RECONCILE_TYPE=nvl($P{P_RECONCILE_TYPE},RECONCILE_TYPE)

ORDER BY STUDENT_ID ASC

SUB REPORT EXPRESSION IN SUBREPORT PROPERTIES WILL BE

$P{SUBREPORT_DIR}+File.separator+ “SLS_STOCK_SALES_REPORT_subreport1.jasper”

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-49304906-2’, ‘wordpress.com’);
ga(‘send’, ‘pageview’);

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-49304906-2’, ‘wordpress.com’);
ga(‘send’, ‘pageview’);

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-49304906-2’, ‘wordpress.com’);
ga(‘send’, ‘pageview’);