Hi all,
How to read and import .csv file in groovy on grails. I have .csv file with data and
need to import in to db using user interface .
thanks in advance,
srinath
Hi,
I'm using g:datePicker name="date1" id="date1" value="${program?.startDate}"
In controller when used params.date1 it is showing value as "struct" and unable to save date in my database.
How can we parse date in to one param like eg: 2010-10-10 11:11:11 using datePicker ?
thanks in advance
srinath
Hi all,
I'm actively developing grails portlets for liferay till today .
I was wondering is there a future road map for next plugin releases and updates for portlet support, because i was not finding people developing portlet applications on grails on net.
Is there any portlet applications running under production ?? .
could any one please provide links if any ?
thanks,
srinath
Hi,
Is there a variable where we can find out the root directory of my Grails application?
I tried request.getSession().getServletContext().getRealPath("/")
But shows tmp/App-Test-0.1/ .
My app is located in tomcat "/home/srinath/work/projects/tomcat-6.0.18/webapps/App-Test-0.1"
could any one help me .
thanks in advance,
sri..
Hi,
Can any one tell me when this error occurs . I suspect this is coming when added any new js in Grails .
I'm unable to dig this :
16 Apr, 2010 4:58:25 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already. Could not load org.codehaus.groovy.grails.plugins.codecs.HTMLCodecBeanInfo. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
thanks in advance,
srinath
Hi,
I'm newbie to groovy/grails.
How to implement thread for this code . Had 2500 urls and this was taking hours of time for checking each url. so i decided to implement multi-thread for this :
Here is my sample code :
def urls = [
"http://www.wordpress.com",
"http://67.192.103.225/QRA.Public/" ,
"http://www.subaru.com",
"http://baldwinfilter.com/products/start.html"
]
def up = urls.collect { ur -
try {
def url = new URL(ur)
def connection = url.openConnection()
if (connection.responseCode == 200) {
return true
} else {
return false
}
} catch (Exception e) {
return false
}
}
For this code i need to implement multi-threading .
Could any one please suggest me the code.
thanks in advance,
sri.
Hi,
how can we write queries on 2 databases .
I installed datasources plugin and domain classes are :
class Organization {
long id
long company_id
String name
static mapping = {
version false
table 'organization_'
id column : 'organizationId'
company_id column : 'companyId'
name column : 'name'
}
}
class Assoc {
Integer id
Integer association_id
Integer organization_id
static mapping = {
version false
table 'assoc'
id column : 'ASSOC_ID'
association_id column : 'ASSOCIATION_ID'
organization_id column : 'ORGANIZATION_ID'
}
}
this is working :
def org = Organization.list()
def assoc = Assoc.list()
and this is not working :
def query = Organization.executeQuery("SELECT o.name as name, o.id FROM Organization o WHERE o.id IN (SELECT a.organization_id FROM Assoc a )")
error :
org.hibernate.hql.ast.QuerySyntaxException: Assoc is not mapped [SELECT o.name as name, o.id FROM org.com.domain.Organization o WHERE o.id IN (SELECT a.organization_id FROM AssocOrg a )]
How can we connect with 2 databases using single query ?
thanks in advance .
I want to have a progress bar (e.g. 200 links total, 20 done, therefore 10% complete).
The bar should show when i click on button "validate now" .
My requirement is to check 2000 urls which are working or not . This was taking a lot of time while executing in program . so i need to show a progress bar on user end to know the status
Can any one please help me using on javascript .
thanks,
sri..
How to sort string names in array on ascending order .
I tried sort method but it fails to sort on name basis .
def words = ["orange", "blue", "apple", "violet", "green"]
I need to achieve like this :
["apple", "blue", "green", "orange", "violet" ]
thanks in advance.
I wrote logic for testing urls using threads.
This works good for less number of urls and failing with more than 400 urls to check .
class URL extends Thread{
def valid
def url
URL( url ) {
this.url = url
}
void run() {
try {
def connection = url.toURL().openConnection()
connection.setConnectTimeout(10000)
if(connection.responseCode == 200 ){
valid = Boolean.TRUE
}else{
valid = Boolean.FALSE
}
} catch ( Exception e ) {
valid = Boolean.FALSE
}
}
}
def threads = [];
urls.each { ur -
def reader = new URL(ur)
reader.start()
threads.add(reader);
}
while (threads.size() 0) {
for(int i =0; i < threads.size();i++) {
def tr = threads.get(i);
if (!tr.isAlive()) {
if(tr.valid == true){
threads.remove(i);
i--;
}else{
threads.remove(i);
i--;
}
}
}
Could any one please tell me how to optimize the logic and where i was going wrong .
thanks in advance.
Hi,
How to redirect to new different form page in Grails portlets .
When click on "New User" it should show new.gsp (here).
but this is not happening and always redirects to view.gsp .
I'm using like this in view.gsp :
a href="${portletResponse.createActionURL()}" name="new_user" id="new_user"New User
please suggest me .
Hi,
I was getting issue wen using new Sql method in grails .
import groovy.sql.Sql
def datasource
def organization_config = new Sql(dataSource)
def orgs = organization_config.rows("select o.organizationId,o.name from organization o ")
session.setAttribute("org_results", orgs);
The application is running but getting these errors when restart tomcat server.
SEVERE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: groovy.sql.GroovyRowResult
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: groovy.sql.GroovyRowResult
Can any one please tell me wy this is coming .
thanks in advance,
sri..
Hi,
How to include security roles in grails portlets for liferay ?
After deploying war in tomcat i added manually these lines for roles
liferay-portlet.xml :
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
portlet.xml :
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
But How to add these roles settings in grails app before creating war ??
Please suggest me .
thanks in advance
sri..
Hi ,
How to implement pagination in grails portlet on Liferay.
The basic pagination was not working on Liferay. When clicked on next the page is jumping from Liferay url to normal url
I used like this :
<g:paginate next="Forward" prev="Back"
maxsteps="10" controller="book"
action="list" total="${Book.count()}" />
thanks in advance.
Hi all,
How can we check whether urls are working or not in groovy?
when we click a button, i will get all the urls from existing db from 'urls' table and need to check which url is working
Ex:
http://baldwinfilter.com/products/start.html - not working
http://www.subaru.com/ - working
and so many urls from db.
My aim is to get all urls and check which one is working and which is not .
do we need to check on the status it returns ??
Can any one help me giving idea ...
thanks in advance
sri...
Hi,
How to catch duplicate key exceptions in Grails . when trying to save existing integer for a unique column constraint, the error is generating while saving/updating a record .
Also used
try{
object.save(flush:true)
}catch(org.springframework.
dao.DataIntegrityViolationException e){
println e.message
}catch(org.hibernate.exception.ConstraintViolationException ex){
println e.message
}catch(Exception e){
println e.message
}
But unable to catch this issue .
23:41:13,265 ERROR [JDBCExceptionReporter:101] Duplicate entry '1' for key 2
23:41:13,281 ERROR [AbstractFlushingEventListener:324] Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
Could you please share the solution to solve this .
Hi,
How to get file name from these lines using groovy .
File file = new File(SOURCE_FILE_NAME).eachLine{line-
println line
}
getting line like this :
/usr/local/testing.groovy
/usr/local/picture.jpg
expecting output:
testing.groovy
picture.jpg
Can any one help me using any if regex needed .
thanks
Hi,
My requirement needs to insert thousands of records and when inserting each new record it was taking more time to finish the job.
Could any one please suggest how to use batches in grails ?
thanks in advance,
sri
I want to declare an Array and all items present in the ListBox Should Be deleted irrespective of the Group name present in the ListBox. can any body help me coding in Python. I am using WINXP OS & Python 2.6.
I was trying out this example at https://github.com/litl/rauth/blob/master/examples/linkedin-web.py
I get a 403, Access to connections denied error and it returns KeyError: '_total'.
r_network option is present. Has anyone faced this issue?
Also if you look at http://docs.python-requests.org/en/latest/user/quickstart/#oauth-authentication, the 'requests' library is initializing resource_owner_key, resource_owner_secret apart from the application keys. Not sure how these are getting passed from the 'rauth' library, Was wondering if that was causing this 403 error.
Hi
This problem exists only in IE browser, in mozilla its working fine... i have to delete a row on click on checkbox....
Here is my code :
<table width="100%" id="seller">
<tr id="row_1" class="row">
<td><input type="checkbox" name="delete" id="delete" value="1" /></td>
</tr>
<tr id="row_2" class="row">
<td><input type="checkbox" name="delete" id="delete" value="2" /></td>
</tr>
</table>
<input type="button" id="delete" name="delete" value="Delete" onclick="delete_row('seller')"/>
var delete_ids = [];
function delete_row(tableID){
var rows = document.getElementsByClassName('row');
var delItems = document.getElementsByName('delete');
for(var i=0;i < rows.length;i++){
alert(delItems[i].checked);
if(delItems[i].checked == true){
delete_ids.push(rows[i].id);
jQuery(rows[i]).remove();
i = i-1;
}
}
}
Showing error on page : 'checked' is null or not an object.
can one please tell me the fix .
thanks in advance,
sri..
I know this is simple question but taking more time
How to find first record from table in grails .
I need to get only the first record with out knowing the id number .
Is there any method like find :first in grails ?
thanks in advance .
I know this is simple thing, but i was not aware.
I used println in gsp file and expected to print output in console. But this is showing on page.
<% for(int i =0; i < threads.size();i++) {
println i
} %
thanks.
I want to declare an Array and all items present in the ListBox Should Be deleted irrespective of the Group name present in the ListBox. can any body help me coding in Python. I am using WINXP OS & Python 2.6.