Page 1 of 2
Custom Component : How send a message of error to client in preview mode?
Posted: Tue Nov 15, 2011 10:39 am
by proexito
Hi,
I have a custom component that implements StiComponentGdiPainter.
On Paint method, I want to send a message of error to client in some cases only in preview mode.
I was trying to use Report.WriteToReportRenderingMessages(), without success,
What do I need to do ?
namespace Sample
{
public class ComponenteGdiPainter : StiComponentGdiPainter
{
public override void Paint(StiComponent component, StiPaintEventArgs e)
{
Componente customComponent = component as Componente;
if (!component.IsDesigning){
//Here I want to send some error to client
if (customComponent.Left==100){
string aa = string.Format("Code can't be processed '{0}' !", 100);
StiLogService.Write(this.GetType(), aa);
customComponent.
Report.WriteToReportRenderingMessages(aa);
return;
}
else
......
}else
.......
}
}
}
Custom Component : How send a message of error to client in preview mode?
Posted: Wed Nov 16, 2011 9:38 am
by proexito
Update:
When I use the function Report.WriteToReportRenderingMessages Inside of customComponent (StiComponent)
namespace sample
{
public class CodigoComponente : StiComponent
{
public override double Height
{
Report.WriteToReportRenderingMessages("TEST");//Here work without trouble
}
}
}
work flawlessly but inside of ComponenteGdiPainter (StiComponentGdiPainter) don't.
Why instance of Report in StiComponent its diferent of instance in StiComponentGdiPainter
if you check here [StiComponentGdiPainter]
public override void Paint(StiComponent component, StiPaintEventArgs e)
I supposed the StiComponent component was the current instance of CodigoComponente : StiComponent, but something happens
When I Call component.Report.WriteToReportRenderingMessages("TEST");//Here Doesn't work
Its these a BUG?
Custom Component : How send a message of error to client in preview mode?
Posted: Wed Nov 16, 2011 11:22 am
by proexito
How reproduce these throuble on project CustomComponent located in Samples\C#\CustomComponent
Open file MyCustomComponentWithExpression.cs
add after the last #endregion
private double height;
public override double Height
{
get
{
StiReport report = (StiReport)this.GetReport();
if (report != null)
{
if (this != null)
{
height = base.Height;
if (!this.IsDesigning)
{
Report.WriteToReportRenderingMessages("TEST inside Height");
}
}
}
return height;
}
}
Then open file MyCustomComponentWithExpressionGdiPainter.cs
and type inside the Paint method :
component.Report.WriteToReportRenderingMessages("TEST inside Paint");
The run app select the component 3 and add to design
press PREVIEW TAB
Now only you see "TEST inside Height" on Report Rendering Messages
Never see "TEST inside Paint"
Custom Component : How send a message of error to client in preview mode?
Posted: Wed Nov 16, 2011 12:02 pm
by Andrew
Hello,
The WriteToReportRenderingMessages method works correctly.
But the pop-up window displays only the messages that appeared during the report rendering and you try to add this message while the rendered report is displayed.
Workaround:
1) The most simple and clear one is to display the required message instead of the ComponenteGdiPainter component.
2) Create your own ComponenteV2Builder and display in it a message, when rendering a report.
Thank you.
Custom Component : How send a message of error to client in preview mode?
Posted: Wed Nov 16, 2011 5:05 pm
by proexito
Thanks Andrew.
But my trouble its about a value get from field evaluated in run time through an expression {VALUE}
I implement
public class CodigoComponenteBuilderV2 :
StiComponentV2Builder
{
public override StiComponent InternalRender(StiComponent masterComp) {
CodigoComponente renderedComponent = base.InternalRender(masterComp) as CodigoComponente;
renderedComponent.Report.WriteToReportRenderingMessages("->>"+renderedComponent.CodigoProcesadoValue);
return renderedComponent;
}
}
and inside of StiComponent
I have
private string codigoProcesado = null;
[
Browsable(false)
][
StiSerializable(StiSerializeTypes.SerializeToDocument)
] public string CodigoProcesadoValue
{
get
{
return codigoProcesado;
}
set
{
codigoProcesado = value;
}
}
and get his value from StiUnifiedExpression
when I debug, I saw how codigoProcesado get the value first then call StiComponentV2Builder
But here again
if when I try to use some logic based on renderedComponent.CodigoProcesadoValue these always is null
It's no possible use Report.WriteToReportRenderingMessages here.
renderedComponent.Report.WriteToReportRenderingMessages("->>"+renderedComponent.CodigoProcesadoValue);
How can inform to the user of an error on preview maybe instead of "report rendering" to error tab?
Custom Component : How send a message of error to client in preview mode?
Posted: Fri Nov 18, 2011 1:09 am
by Alex K.
Hello,
First, it is not correct to display a message in the painter.
Second, Report.WriteToReportRenderingMessages() is not correct way to do. Messages are collected there during the report compilation, and immediately are output before rendering.
Thank you.
Custom Component : How send a message of error to client in preview mode?
Posted: Fri Nov 18, 2011 7:27 am
by proexito
I m agree with you only in Report.WriteToReportRenderingMessages() cant send messages on painter
But my necessities are send messages there because only you get data from datasource in that point from {tag}.
Suppose you have some special calculus using database values and with these values you get null pointer how you can inform to your user preview about that.
Custom Component : How send a message of error to client in preview mode?
Posted: Fri Nov 18, 2011 8:07 am
by HighAley
Hello.
proexito wrote:I m agree with you only in Report.WriteToReportRenderingMessages() cant send messages on painter
But my necessities are send messages there because only you get data from datasource in that point from {tag}.
Suppose you have some special calculus using database values and with these values you get null pointer how you can inform to your user preview about that.
You can write a message like in the attached report template.
Thank you.
Custom Component : How send a message of error to client in preview mode?
Posted: Fri Nov 18, 2011 9:21 pm
by proexito
THANK YOU Aleksey Andreyanov
This simple solution I can sow it before you write this post.
Thanks to Andrew too.
SOLUTION ACCEPTED.
PD.
I don't know how close this post.
Custom Component : How send a message of error to client in preview mode?
Posted: Sat Nov 19, 2011 12:26 am
by Andrew
Hello,
Great! Have a nice day!
Thank you.