vahidhedayati / grails-wschat-plugin

Grails websocket chat Plugin provides a multi-chat room add-on to an existing grails based site. provides: Private Messaging/WebRTC/Offline PM + room booking/reservations. Websocket TicTactoe. Add Live Chat to your Grails application
http://grails.org/plugin/wschat
Apache License 2.0
22 stars 10 forks source link

viewusers paginationParams #20

Closed charleslin1022 closed 8 years ago

charleslin1022 commented 8 years ago

Hi, I set over 10 user in Bootstrap.groovy, and open the the "view users" page. When I click page2 to change page, the console has error message "could not resolve property: null of: grails.plugin.wschat.ChatUser". It seems some params in searchBean is null, how can I fix it?

vahidhedayati commented 8 years ago

I will take a look it's probably a requirement to add some of the values passed by pages nation which bean doesn't recognise. If your 2nd page link produces any format of output of what it's sending through for next page in you development console paste it here. That will then help ease the identification without me repeating steps initially

charleslin1022 commented 8 years ago

First, I add some code in BootStrap.groovy as following:

import grails.plugin.wschat.ChatLog
import grails.plugin.wschat.ChatPermissions
import grails.plugin.wschat.ChatUser
import grails.plugin.wschat.ChatUserProfile

class BootStrap {
    def init = { servletContext ->
        addUser('admin','admin')
        addUser('user01','user')
        addUser('user02','user')
        addUser('user03','user')
        addUser('user04','user')
        addUser('user05','user')
        addUser('user06','user')
        addUser('user07','user')
        addUser('user08','user')
        addUser('user09','user')
        addUser('user10','user')
    }
    def destroy = {
    }

    void addUser(String username, String permission) {
        ChatUser user
        ChatPermissions perm

        perm = ChatPermissions.findByName(permission)
        perm = perm ? perm : new ChatPermissions(name: permission).save(flush: true)
        user = ChatUser.findByUsername(username)
        if (!user) {
            def addlog = addLog()
            user = new ChatUser(username: username, permissions: perm, log: addlog, offlog: addlog).save(flush: true)
        }
        ChatUserProfile.findOrSaveWhere(chatuser: user).save(flush: true)
    }

    private ChatLog addLog() {
        ChatLog logInstance = new ChatLog(messages: [])
        if (!logInstance.save()) {
            log.debug "${logInstance.errors}"
        }
        return logInstance
    }
}

Second, I print the viewUsers function in WsChatService.groovy, and the "paginationParams" in 1st page is ok, like this "[sort:lastUpdated, order:desc, offset:0, max:10]". When click 2nd page, the the "paginationParams" is [sort:null, order:null, offset:0, max:10]. Params "sort" and "order" are null, and the following code is error message:

Error |
2016-03-16 17:41:35,023 [http-bio-8080-exec-11] ERROR errors.GrailsExceptionResolver  - QueryException occurred when processing request: [POST] /wschat1.29test/wsChat/viewUsers - parameters:
id: null
sortby: null
max: null
order: null
s: null
pageSizes: null
offset: 10
divupdate: null
viewtype: na
could not resolve property: null of: grails.plugin.wschat.ChatUser. Stacktrace follows:
Message: could not resolve property: null of: grails.plugin.wschat.ChatUser
    Line | Method
->>   54 | <init>          in grails.orm.PagedResultList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    109 | $tt__viewUsers  in grails.plugin.wschat.WsChatContService
|    298 | renderViewUsers in grails.plugin.wschat.WsChatController
|    287 | viewUsers       in     ''
|    198 | doFilter . . .  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter        in grails.plugin.cache.web.filter.AbstractFilter
|     53 | doFilter . . .  in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
|     62 | doFilter        in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|     59 | doFilter . . .  in grails.plugin.springsecurity.web.SecurityRequestHolderFilter
|   1145 | runWorker       in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run             in java.lang.Thread
vahidhedayati commented 8 years ago

I have just released 1.31 which should fix this issue. I have also fixed the modal box so that it extends the entire page.

There is also new additional functionality to remove the user, it attempts to remove the user and spring security user as well if that also exists.

charleslin1022 commented 8 years ago

Hi, I try version 1.31, and the problem is solved. Thanks.