Custom Component : How send a message of error to client in preview mode?
Custom Component : How send a message of error to client in preview mode?
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
.......
}
}
}
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?
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?
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?
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"
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?
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.
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?
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?
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?
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.
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?
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.
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?
Hello.
Thank you.
You can write a message like in the attached report template.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.
Thank you.
- Attachments
-
- 1432.Report.mrt
- (3.38 KiB) Downloaded 142 times
Custom Component : How send a message of error to client in preview mode?
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.
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?
Hello,
Great! Have a nice day!
Thank you.
Great! Have a nice day!
Thank you.