Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Nazeer Ahammad

Ranch Hand
+ Follow
since Feb 26, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nazeer Ahammad

hi all,

How to read .properties file which is in WEB-APP folder in grails ?

please help me....



Regards,
Nazeer
4 years ago
Hi All,

How to get database connection details(url,username,password and drivername...) in grails which is represented in ......\grails-app\conf\DataSource.groovy .



Please help me...

Regards,
Nazeer,,,,,
4 years ago
Hi,

I'm writting one grails application in that i have display records from database that is completed and now if i will click on add button one empty grid row has to add to that grid table.
I'm using grails(2.2.3) and jqgrid(1.3.8.0) pluging.

Please help me............

Regards,
Nazeer
4 years ago
Hi All,

How to get connection object in grails(version 2.2.4)?

Regards,
Nazeer......
4 years ago
Hi got the answer ..............................


If i use below code in gsp it is working

<g:set var="colnames" value="${new MyController().colnames()}" />
<script>
$(document).ready(function() {
...................

colNames="${colnames}"

....................

</script>

And i altered the controller like below
------------------------------------------
Class MyController
{
def colnames()
{
return "id,name".toString()
}
}


Same for coldetails also


Regards,
Nazeer
4 years ago
Hi All,

I'm using JQgrid plugin(version 1.3.8) in grails (vesrion 2.2.4) .I want get colNames and ColModel from controller. How we can get this one ?

Example:-

__________
Controller
__________

MyController{

def columndetails={
def columnname="id,name"
render columnname as json
}

def colmodeldetails={
def details="{name:'companyname', editable: true},{name:'id',hidden:true}"
render details as json
}
}

_______
GSP
________
$(document).ready(function() {

// $.ajax({url: 'http://localhost:8080${createLink(action: 'colnames')}', success: function(data) { alert('hai'); } });
//alert("'${createLink(action: 'colnames')}'");
<jqgrid:grid
id="contact"
url="'${createLink(action: 'listJSON')}'"
editurl="'${createLink(action: 'editJSON')}'"
colNames= //Here what i have to written to call columndetails to get column names from Mycontrollee
colModel= //Here what i have to written to call colmodeldetails to get column details from Mycontrollee
sortname="'companyname'"
caption="'Company List'"
height="300"
autowidth="true"
scrollOffset="0"
viewrecords="true"
showPager="true"
datatype="'json'"
beforeSelectRow= "function (id) {
if (id !== lastsel2) {
jQuery(this).restoreRow(id,true);
lastsel2 = id;
}
return true;
}"

ondblClickRow="function(id)
{
var rowData = jQuery(this).editRow(id,true);
lastsel2=id;
}"



>

<jqgrid:filterToolbar id="contact" searchOnEnter="false" />
<jqgrid:navigation id="contact" add="true" edit="true"
del="true" search="true" refresh="true"
/>


<jqgrid:resize id="contact" resizeOffset="-2" />
</jqgrid:grid>







});


Regards,
Nazeer.....
4 years ago
Hi All,

I'm using jqgrid plugin(version is 1.3.8) in grails(version is 2.2.4), inline edit is working but how to achieve inline insertion?

Please see the below code
------------------------------
<head>

<jq:resources />
<jqui:resources />
<jqgrid:resources />


<script type="text/javascript">


var lastsel2;
// var colnames='${createLink(action: 'colnames',params:'columnnames')}';
//alert(colnames);
$(document).ready(function() {

<jqgrid:grid
id="contact"
url="'${createLink(action: 'listJSON')}'"
editurl="'${createLink(action: 'editJSON')}'"
colNames="'companyname', 'exp','id'"
colModel="{name:'companyname', editable: true},
{name:'exp', editable: true},
{name:'id', hidden: true}"
sortname="'companyname'"
caption="'Company List'"
height="300"
autowidth="true"
scrollOffset="0"
viewrecords="true"
showPager="true"
datatype="'json'"
beforeSelectRow= "function (id) {
if (id !== lastsel2) {
jQuery(this).restoreRow(id,true);
lastsel2 = id;
}
return true;
}"

ondblClickRow="function(id)
{
var rowData = jQuery(this).editRow(id,true);
lastsel2=id;
}"



>

<jqgrid:filterToolbar id="contact" searchOnEnter="false" />
<jqgrid:navigation id="contact" add="false" edit="true"
del="true" search="true" refresh="true"
/>


<jqgrid:resize id="contact" resizeOffset="-2" />
</jqgrid:grid>







});


</script>

</head>
<body bgcolor="#c0c0c0">

<jqgrid:wrapper id="contact" />
<input type="button" id="addrow" value="insert">
</body>
-------------------------------
controller is
------------------
class UserController {


def messageSource
//def scaffold = Precompany

def defaultAction = "index"

def editJSON = {
def result
def message = ""
def state = "FAIL"
def id

// determine our action. Grid will pass a param called "oper"
switch (params.oper) {
// Delete Request
case 'del':
result = Precompany.get(params.id)
if (result) {
result.delete()
message = "Author '${result.companyname} ${result.exp}' Deleted"
state = "OK"
}
break;
// Add Request
case 'add':
result = new Precompany(params)
break;
// Edit Request
case 'edit':
// add or edit instruction sent
result = Precompany.get(params.id)
result.properties = params
break;
}

// If we aren't deleting the object then we need to validate and save.
// Capture any validation messages to display on the client side
if (result && params.oper != "del") {
if (!result.hasErrors() && result.save(flush: true)) {
message = "Author '${result.companyname} ${result.exp}' " + (params.oper == 'add') ? "Added" : "Updated"
id = result.id
state = "OK"
} else {
message = "<ul>"
result.errors.allErrors.each {
message += "<li>${messageSource.getMessage(it)}</li>"
}
message += "</ul>"
}
}

//render [message:message, state:state, id:id] as JSON
def jsonData = [messsage: message, state: state, id: id]
render jsonData as JSON
}

def listJSON = {
def sortIndex = params.sidx ?: 'name'
def sortOrder = params.sord ?: 'asc'

def maxRows = Integer.valueOf(params.rows)
def currentPage = Integer.valueOf(params.page) ?: 1

def rowOffset = currentPage == 1 ? 0 : (currentPage - 1) * maxRows

def authors = Precompany.createCriteria().list(max: maxRows, offset: rowOffset) {

if (params.companyname)
ilike('companyname', '%' + params.companyname + '%')

if (params.exp)
ilike('exp', '%' + params.exp + '%' )


//order(new Order(params.companyname, params.exp).ignoreCase())

//order(sortIndex, sortOrder).ignoreCase()
//resultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
}
println "listJson"+ authors.totalCount
def totalRows = authors.totalCount
def numberOfPages = Math.ceil(totalRows / maxRows)

def jsonCells = authors?.collect {
[
cell: [it.companyname,it.exp],
id: it.id
]
}

def jsonData= [rows: jsonCells,
page: currentPage,
records: totalRows,
total: numberOfPages]

render jsonData as JSON
}
----------------
Please help me

Regards,
Nazeer.
4 years ago
Hi all,

i'm creating one application, in that i'm using claendar plugin to display date picker field. In GSP i'm going to display 'n' number of date picker fields. If i use same name for all field only first field is working fine, remaining field are not working (means date picker is not working).

Please help me to resolve this problem.....

Regards,
Nazeer
4 years ago
i have used below code to resolve my problem

sql.rows(query) { meta ->
colDataType = (1..meta.columnCount).collect {
meta.getColumnTypeName(it)
}
}
4 years ago
hi all,

how to get column data types using groovy sql?


regards,
nazeer
4 years ago
Hi All,

Is it possible to convert xml tag attributes to map?

For an instance :
<students>
<student name="sname" id="sid" college="collegename">
</students>

by parsing this i have to get map object like [name:"sname", id:"sid",college:collegename]



Regards,
Nazeer
4 years ago
Hi All,

<?xml version="1.0" encoding="UTF-8"?>
<Config-matrix>

<input name="table_name" type="table" >
<column name="colname1" />
<column name="colname2"/>
<column name="colname3" />
<insert name="insert query"/>
<update name="update query"/>
</input>

</Config-matrix>

This is the xml file how to display column name attribute values i.e colname1,colname2,colname3.

Regards,
Nazeer
4 years ago
Hi All,
I need one help. Please see the below xml file content

<students>
<student name="###" id="###" college="###"></student>
<students>

In the above xml, I need to display attribute student tag names(name,id and college).
How can i do this in Groovy.
Please help me.

Thanks,
Nazeer.
4 years ago
Problem is resolved by setting proxy.
Thanks for giving valueble input to resolve this problem.


Regards,
Nazeer...

4 years ago