CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Java: How to hide a Custom Block in Editable Grid

Print topic Send  topic

Author Message
sudheer

Posts: 11
Posted: 08/02/2006, 2:56 PM

Hi,
I have an editable grid 'empGrid'.
At the end of the grid, I have a Custom Block with a Totals row that sums up all the grid values.
I would want to hide this Custom Block when the no records message gets generated.
I tried with the following code in the before show event of the editable grid.

Template tmpl = e.getPage().getTemplate();
String currentPath = e.getPage().getCurrentPath();
String pid = e.getPage().getHttpGetParams().getParameter("id");
if (pid == null) {
tmpl.setVar(currentPath+ "/empGrid/TotalsBlock", "");
} else {
tmpl.parse(currentPath+ "/empGrid/TotalsBlock",false);
}

With the above code in the BeforeShow handler, the page doesn't comeup in the browser.
When debugged, I found that:

1 - The 'Event' parameter to beforeShow() method is of type Component
2 - e.getPage().getCurrentPath() returning 'main'
3 - e.getPage().getPagePath() returns null
4 - e.getPage().getTemplate() returns null
5 - e.getPage() returns null

Can anyone let me know how to hide a custom block in the editable grid.

Note: Coding Env: JSP

-Sudheer

View profile  Send private message
matheus

Posts: 386
Posted: 08/03/2006, 5:06 AM

I cannot understand.

Your CustomBlock is a Panel?

You can set Visible false your "Custom Block".
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
sudheer

Posts: 11
Posted: 08/03/2006, 8:52 AM

Hi Mathews,

I am not sure if the CustomBlock is considered as a Panel in CodeCharge.
My only purpose of the custom block is to conditionally disable it.

I have this custom block in between "Row" and 'NoRecords" blocks in the editable grid.
I tried the following code in the BeforeShow of the EditableGrid. But couldn't get done with what I wanted to.
"....
String pid = e.getPage().getHttpGetParams().getParameter("id");
Template tmpl = e.getPage().getTemplate();
String currentPath = e.getPage().getCurrentPath();

if (pid != null && pid.length()>0) {
tmpl.parse(currentPath+ "/MyBlock",false);
} else {
tmpl.setVar(currentPath+ "/MyBlock", "");
}

..."

When I debugged the above calls, I observed that 'tmpl' is null.

Hope this helps in a better understanding of the problem.

Thanks,
-Sudheer

View profile  Send private message
sudheer

Posts: 11
Posted: 08/03/2006, 9:07 AM

I even tried using

e.getPage().getChild("MyBlock");

It also returned null. Am I doing any mistake anywhere?

-Sudheer
View profile  Send private message
matheus

Posts: 386
Posted: 08/03/2006, 11:10 AM

Hm.. seems like your Custom Block is only writted in HTML and had some label....

You can try create a Panel, put all this inside. Must stay like this:
  
<!-- Begin Row -->  
....  
<!-- End Row -->  
<!-- Begin Panel CustomPanel -->  
...  
your CustomBlock (in HTML)  
.....  
<!-- End Panel CustomPanel -->  
<!-- Begin NoRecords -->  
no records.  
<!-- End NoRecords -->  
So you can try setVisible to your panel. Your panel will be inside the EditableGrid, so need call like this in Before Show from EditableGrid:
---------------------------
  
String pid = e.getPage().getHttpGetParams().getParameter("id");  
  
if (pid != null && pid.length()>0) {  
     e.getEditableGrid().getPanel("CustomPanel").setVisible(false);  
}else{  
   e.getEditableGrid().getPanel("CustomPanel").setVisible(true);  
}  

So, when the parameter doesn't appear, your Custom Block doesn't appears.

Sorry my english.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
sudheer

Posts: 11
Posted: 08/03/2006, 12:54 PM

Hi Mathews,
Thank you for prompt reply.
I tried the code but invein.
This time it says
"... method getPanel (java.lang.String) cannot be resolved.."
I went through the methods of EditableGrid and I dont see such method anywhere in the hierarchy - EditableGrid, Grid, Component.
Are you sure the panel is available in JSP.?
I am using CCS2.3.2

-Sudheer
View profile  Send private message
WKempees
Posted: 08/03/2006, 2:46 PM

No Not in CCS2+, is feature of CCS 3+

"sudheer" <sudheer@forum.codecharge> schreef in bericht
news:944d25469d23e5@news.codecharge.com...
> Hi Mathews,
> Thank you for prompt reply.
> I tried the code but invein.
> This time it says
> "... method getPanel (java.lang.String) cannot be resolved.."
> I went through the methods of EditableGrid and I dont see such method
> anywhere in the hierarchy - EditableGrid, Grid, Component.
> Are you sure the panel is available in JSP.?
> I am using CCS2.3.2
>
> -Sudheer
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

sudheer

Posts: 11
Posted: 08/03/2006, 3:32 PM

Hi WKempees,

How can I do the same in CCS2+? Any idea?
-Sudheer


View profile  Send private message
matheus

Posts: 386
Posted: 08/04/2006, 4:41 AM

Hm... CCS2....

In CCS2 you need use a Label with HTML content.

Put a Label: CustomLabel.

In BeforeShow of Label put all Custom Block.

Use Label with ExtendedHTML to use visible.

Then you can visible true or false in a Label.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
jres
Posted: 08/07/2006, 10:38 PM

e.getPage().getTemplate() works only for ServletTemplates pattern
for JSP you can try
e.getPage().getBlock("MyBlock").setVisible(false);

sudheer

Posts: 11
Posted: 08/08/2006, 10:36 AM

HI Jres,

This isn't working.
e.getPage().getBlock("myBlock") is returning null.

Any other alternatives?

-Sudheer
View profile  Send private message
matheus

Posts: 386
Posted: 08/08/2006, 11:46 AM

e.getPage().getControl("myBlock")
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
jres
Posted: 08/09/2006, 12:50 AM

Hi sudheer,

it is very strange that you got null.
I think this code
  
    public Block getBlock(String path) {  
      Block b;  
      b = (Block)blocks.get(path);  
      if (b == null) {  
        b = new Block(path.substring(path.lastIndexOf("/")));  
        blocks.put(path, b);  
      }  
      return b;  
    }  
can't return null.

please check method com.codecharge.components.Page.getBlock in generated code.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.