I’m trying to automate the downloading of a report from a website (using a WebBrowser).
I have successfully done so for a report in the past, but now find myself having to select an entity from a dropdown list in order to generate a new table of reports for that entity. I can change the index of the list but it will not generate the table of reports I need.
I used the “inspect” feature on Chrome to debug the code and see where the table is being generated, but my understanding of JavaScript is about 3 shades above non-existent.
It appears that when I click the option, it is firing off an “onChange” event that is not occurring when I simply choose the options (makes sense). So, I am attempting to manually fire off this onChange event, but am admittedly getting in a little over my head with this. It appears I need to do a bit more reading on JavaScript and probably the WebBrowser library in Delphi.
I feel like I am missing a key concept in the relationship between Delphi, HTML, and JavaScript. I'm not even sure if I can fire off the event via Delphi (I need to find a way to emulate an event such that the Listener will pick up the entityChanged event). I'm going in mental circles here trying to wrap my head around this and am hoping that I'm missing something very simple and basic.
My code (breaks on the Element.FireEvent, again the values I ascertained through debugging):
procedure TForm3.runReport;
var
Document : IHTMLDocument2;
Element : IHTMLElement3;
begin
try
Document := Form3.WebBrowser1.Document as IHTMLDocument2;
Element := Document.forms.item('l4iHkfgk6Nk%3D_store_11157_6%2F18%2F2014%2012%3A00%3A00%20AM',NULL) as IHTMLElement3;
Element.FireEvent('entityChanged','Txxxxxxxxxxx (11157),l4iHkfgk6Nk=_store_11157_6/18/2014 12:00:00 AM,February 10 2017,entity');
except
rptSt := 1;
end;
end;
Here is what I found about the Event Listener for the selection:
And here is the function that is called when I debug the event:
I apologize in advance if there is too much ambiguity in this; I tried to be as clear as possible.
Related
The context is that I am maintaining an application running on delphi 7 with the BDE. I programmatically assign dbricheditcontrols' datafields to allow users to edit rtf documents. When the relevant forms open, the unformatted text is displayed and then once say the person moves onto the next document, suddenly the rich text kicks in; I suspect it must be an initialisation problem of sorts, but what am I missing; could not locate a solution online.
Thanks
Ordinarily, I would not post an answer to a q which states
I programmatically assign dbricheditcontrols' datafields to allow users to edit rtf documents
but fails to include the code that you are using - you should have provided an MCVE (see https://stackoverflow.com/help/mcve).
However, what you say sugggests that you may be going about what you are trying to do the wrong way. You say you are using a TDBRichEdit component, but if you are using it correctly, it should not require any programmatic assignment of datafields to do it: you simply need to connect the component to the TTable or TQuery you are using via a TDataSource component, and configure the DBRichEdit to access whatever field of the TTable/TQuery that stores the richedit text. That can be done a design time using the Object Inspector in the IDE to set properties and does not require any code.
So, it seems to me that either you are not using the DBRichEdit correctly, or you are trying to do something that you have not explained in your q.
You can satisfy yourself that a DBRichEdit works automatically, without needing to load or save its contents in code, as follows:
Open the FishFacts demo
Add a TDBNavigator and a TDBRichEdit to the form. Set the DataField property of DBRichEdit1 to Notes.
Set the ReadOnly property of Table1 to False. Then set Table1's Active property to True.
Compile and run the project. While it's running
Start WordPad.Exe and create a bit of richtext in it. Copy it to the clipboard. Click the Save speedbutton of DBNavigator1.
Paste the richtext into DBRichEdit1.
You should find that you can navigate away from and back to the edited record and the richtext will be automatically reloaded.
Also, the following code works fine for me to load the Notes field from an .Rtf file
procedure TForm1.Button1Click(Sender: TObject);
begin
Table1.Edit;
TMemoField(Table1.FieldByName('Notes')).LoadFromFile('D:\test.rtf');
end;
and does not initially display the unformatted text as you describe. So I'm fairly sure you problem is arising in code of yours that you haven't shown us.
Btw, the only reason I am posting this as an "answer" is that there is more to say than will comfortably fit in a comment.
My Delphi project has a TAdoQuery accesssing data on an MS Sql Server 2014 server, and TClientDataSet that receives the AdoQuery data via a TDataSetProvider. This is created from a Project Template I set up.
Normally, I've found this set-up to work faultlessly, but with this particular project I'm having a problem: ApplyUpdates() fails silently and the Sql Server data is not updated. In my stripped down debugging project, the only code I have, apart from a button-click handler which calls it, is:
procedure TForm1.ApplyUpdates;
var
Errors : Integer;
begin
Errors := ClientDataSet1.ApplyUpdates(0);
Caption := IntToStr(Errors) + '/' + IntToStr(ClientDataSet1.ChangeCount);
end;
After this executes, the form's caption should be 0/0 of course but what it actually says is 0/1. So on the face of it, no errors occurred but the CDSs ChangeCount hasn't been reset to zero as it should be. My q is, how can ApplyUpdates return no errors but the server dataset doesn't get updated.
Fwiw, I added the ChangeCount display as part of my effort to debug the problem. But I'm afraid I haven't been able to follow what's supposed to be going on in the details of the "conversation" between the DataSetProvider and its DataSet to apply the updates on the server.
I ran into this problem recently on a quick project I rustled up without the precaution of setting an OnReconcileError handler, as queried by #mjn.
Once I'd set up the OnReconcileError handler, it was obvious that the problem was that the provider's TSqlResolver wasn't able to identify the row to update. Iirc, the message on the ReconcileError pop-up form was words to the effect of "Unable to locate record. No key specified."
So, first thing I tried was to include this in my CDS's AfterOpen:
CDS1.Fields[0].ProviderFlags := [pfInKey];
(CDS1.Fields[0] is the PK field of the dataset)
Contrary to my expectations, that didn't fix it. After scratching my head for a while, I had a careful look on the server and discovered that the recently-recreated table I was using did not have a primary key index.
Once I'd created the primary key index on the server, the ApplyUpdates problem went away.
However, what puzzles me about this is that prompted by your q, I dropped the primary key index on my server table and the problem hasn't started occurring again (!). I'm guessing this is due to some kind of cacheing effect on my machine but I don't really want to reboot it right now to investigate.
In fastreport VCL 4 is there a way to set headers visibility only on odd pages of report? Found no answer on google, neither on fastreport's site, documentation & forum.
You do it in code. In your page object's OnBeforePrint event, you put some code sort of like this:
procedure PageHeader1OnBeforePrint(Sender: TfrxComponent);
begin
PageHeader1.Visible := (Frac(<Page#> / 2) > 0.01)
end;
Maybe there is an easier way to figure out whether you are on an odd page or not, but I resorted to the Frac function because they don't have a Mod function. In practice, I would probably add that function within my own code and make it accessible within the report.
I'm using the component in delphi indy idhttp 2010 and I have the following problem, I'm trying to get all the values of rawheaders idHTTP1.Request.RawHeaders.Values ['User-Agent'], the only one I know of is user agent and I wonder where I can find the list of values to use in RawHeaders.Values.
Does anyone could help me?
Your question can be read in few ways.
You ask about "to get all the values of rawheaders" - that is "read, not modify".
And then you tell about "values to use in RawHeaders.Values" - which is "write, not read".
Actually it is hard to guess what did you meant here.
Well, if you want to read all the values that are contained there, you are to start from documentation for idHTTP1.Request: http://www.indyproject.org/docsite/html/TIdEntityHeaderInfo.html
There you click on "properties" link, select "RawHeaders" property and - after reading property RawHeaders: TIdHeaderList; - come to http://www.indyproject.org/docsite/html/TIdHeaderList.html
There you read that RawHeaders - just as expected - are a subclass of TStringList thus you can read it with all the usual TStrings-related methods.
Like
idHTTP1.Request.RawHeaders.SaveToFile('1.txt');
s := idHTTP1.Request.RawHeaders.CommaText;
with idHTTP1.Request.RawHeaders do for i := 0 to Count - 1 do begin s := Strings[i]; ... end;
for s in idHTTP1.Request.RawHeaders do begin ... end;
etc.
Alternatively if you want to write some sane and safe values, you are to start from documentation for idHTTP1.Request: http://www.indyproject.org/docsite/html/TIdEntityHeaderInfo.html
There you can see the link to "Hypertext Transfer Protocol version 1.1" where you can find most of them
Or you can add some custom non-standard headers with "X-" prefix, after testing that your server would not break when found them.
Also note that there are some frequently use though non-standard headers or their parameters, like in content-disposition. Some of them are probably retroactively described by communities like HTML5 working group. Or maybe not,
Also note that there are a number of sub-protocols built on top of HTTP. Like WebDAV. Like file transfer in Gnutella2 protocol, etc. They may add their own custom headers, that were not described in their founding HTTP protocol. Read the documentation on those protocols, you may be interested in (if any).
HI,
I created 4 radiobuttons in a intraweb application.
One is checked by default, the rest is not.
The belong to the same group called group. (I set the group properly of each TIWradiobutton)
There is twiimage image which has click event. In that click event, I tried to set the radiobuttons.
E.g.
radiobutton1.checked:=true;
The problem is that this sometimes set the radiobutton and sometimes it does not.
I found a fix by setting the rest of radiobuttons.checked to false. That fixed the problem.
I wonder what I did wrong in the first place when I just used one assignment.
Can you tell me if it is a bug in intraweb or I used radiobutton improperly?
Thanks.
just create a IWRadioGroup1(in iwstanderd pallet ) in your form
select IWRadioGroup1 , in the properties panenel dblclick on items
you will get a stringlist editor ,type the captions of your four radiobuttons line by line then click OK
now select your IWImage1 ,goto click events just type th above code
procedure TformMain.IWImage1Click(Sender: TObject);
begin
IWRadioGroup1.ItemIndex := 2 // 2 is the radiobutton number as you typed in stringlist editor
end;
sometimes IW or components build over the IW (e.g TMS suite for IW) have a strange behavior.you can find how it works by looking out in the code, how they manage the java script behind your radio groups.
Also sometimes you must manage the components exactly how Atozed say in their documentation.
Probably isn't the best answer, but if you'll work a lot with IW you'll see that it has a lots of limitations and strange behavior (only if you don't work in their style, which sometimes differs a lot from win32 style).
best regards,