0

So trying to create a relatively (I thought) simple setup in groovy, and missing a couple of bits.

Basically I am trying to create a webpage with three panes, a title, left side bar and a main window. The title stays as it is, the left pain has a controller for generating reports, the right side shows the output. So far so good, but there are two or potentially three commands or features I do not seem to be able to master, searched but the search therms I used comes up with little useful.

So, first the main .gsp, the one that I would suspect loads the structure. Created a controller and view called calllog. The controller is empty, while the index.gsp contains the following.

  <meta name='layout' content='call-log'/>
<html>
<head>
<title>Call log</title>
</head>
<body>
    <div id="CallLogo"><H1>Call Logger</H1></div>
    <div id="controller">
    <object type="text/html" data="dbstats/index">

    <g:link controller="dbstats" action="index">This is something</g:link>
    </div>
    <div id="output">Your output here</div>
</body>
</html>

Here is my first issue, it does not seem like it is creating the div sections I am expecting, it just outputs it. Secondly, the does not seem to load, and I have not been able to find a operator.

The layout looks as follows

    <!doctype html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><g:layoutTitle default="call-log"/></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <asset:stylesheet src="calllog.css"/>
        <asset:javascript src="call-log.js"/>
        <g:layoutHead/>
    </head>
    <body>
        <div class="CallLogo" id="CallLogo" role="banner"><a href="http://www.google.co.uk"><asset:image src="call.png" alt="call.png"/></a></div>
        <g:layoutBody/>
        <div id="controller" class="controller" role="contentinfo"></div>
        <div id="output" class="output" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
    </body>
</html> 

The next problem I have, which may have the same answer is, how do I call (or do a call back) to a action. So, the dbstats controller will provide a menu, once you press submit, it will call a submit class which stores some data, what I want to be able to do is to get that pane to go back to index, while also start a process to generate output to the "body" pane.

=============UPDATE: One step forward Two steps ... ==================== So getting closer, managed to solve the issues with the layout and divs, did not help that I was editing the wrong CSS file as well.

The webpage looks like this now

-------------------------------
|             Logo            |
-------------------------------
| Con |          Output       |
| tro |                       |
| lle |                       |
| r   |                       |
|     |                       |
-------------------------------   

I managed to update so that the Controller function loads correctly, and there is a list and a submit button and all.

However, what I can't figure out is. Once the Submit button is pressed, and I have read the info I wan't (that works now), how do I either get the Controller reloaded as controller="dbstats" action="index" into the div Controller and call a function to update Output with another controller, say controller=generateGraph action=graph. Tried with redirect which told me:

The code of submitform looks like this currently

def submitForm() {
def postIds = params.list('userform').get(0)
for ( e in session.users) {
    session[e] = "False"
}
postIds.each() { postId ->
    if ( postId.value == "1" ) {
        session[postId.key] = "True"
        //render {
            //div(id: "Output", "Will do ${postId.key}<BR>")
        //}>"
    }
    redirect(action: "CallLog")
  }

} All that giver me is Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.. Stacktrace follows: Message: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.

Would be happy to redraw the whole page id need be.

vrghost
  • 1,084
  • 2
  • 19
  • 42

1 Answers1

0
<!doctype html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><g:layoutTitle default="call-log"/></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <asset:stylesheet src="calllog.css"/>
        <asset:javascript src="call-log.js"/>
        <g:layoutHead/>
    </head>

    <body>
<div id="siteWrapper">
        <div class="CallLogo" id="CallLogo" role="banner"><a href="http://www.google.co.uk"><asset:image src="call.png" alt="call.png"/></a></div>
        <g:layoutBody/>
        <div id="controller" class="controller" role="contentinfo"></div>
        <div id="output" class="output" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
</div>
    </body>

</html> 

--

  <meta name='layout' content='call-log'/>
<html>
<head>
<title>Call log</title>
</head>
<body>
    <div id="CallLogo"><H1>Call Logger</H1></div>
    <div id="controller">
    <object type="text/html" data="dbstats/index">

    <g:link controller="dbstats" action="index">This is something</g:link>
    </div>
    <div id="output">Your output here</div>

    <a  onclick="<g:remoteFunction controller="Something"  action="SomeAction" id="${yourId }" update="siteWreapper"/>"><b>click to update entire site content within body tags</b><br/>


</body>
</html>

Another way is to use javascript get

 $.get("/"+baseapp+"/applications/getOwner?id="+id+"&two="+two,function(data){
                            $('#appOwner').hide().html(data).fadeIn('slow');
                    });

where appowner is the div ID the result will update the get can be getJSON

remoteFunction with params:

<button  id=boxbtn onclick="<g:remoteFunction controller="yourcontroller"  action="br" update="siteContent"  id="${some?.id}"  params="${[s:'e',viewtype:'na']}"/>">some action</button>
V H
  • 8,382
  • 2
  • 28
  • 48
  • vahid: Thank you very much, this does clarify some parts, but I think I am missing one thing. So I want to load the controller in dbstats, and when someone clicks submit, I want the the dbstats controller to update output. So in effect I want to do a – vrghost Sep 19 '14 at 12:11
  • then you need g:remoteForm take a look here https://github.com/vahidhedayati/spring-security-contactus/blob/master/grails-app/views/contactUs/index.gsp this will then update results to a div – V H Sep 19 '14 at 12:35
  • you can also add params to the g:remoteFunction updated answer with the typical format. The javascript to do get take a look in this folder https://github.com/vahidhedayati/ajaxdependancyselection/blob/master/grails-app/views/autoComplete/_selectJs.gsp this is a typical get but getting grails to complete where the controller action is i.e. it will define your application name if called this way – V H Sep 19 '14 at 12:37