Ext - javascript null exception on init - hiddenField - extjs

My Ext (Sencha) page throws this JS error when it initialises:
Uncaught TypeError: Cannot read property 'value' of null - ext-all-debug.js:89797
it errors on this line:
startUp: function () {
var me = this;
me.currentToken = me.hiddenField.value
Because 'hiddenField' is null.
Without pasting the entire page content (it's very big, and under NDA), can anyone tell what I should look for that might be on my page that's causing this?

Looks you're using the History and haven't created the appropriate hidden/iframe elements that it needs. Have a look at the history example for the version you're using.

Related

Pdf Tron error " Exception error: Pdf error not found" (React App)

I'm trying to embed Pdf tron to my React application. I'm receiving this error when I'm clicking on the tab I want to filter to find the relative pdf file.
const handleFilteredDocs = (id)=>{
const filteredDoc = props.location.documents && props.location.documents.filter(doc=>{
return doc.controlId === id
})
setFileteredDoc(filteredDoc)
setPdfPath(filteredDoc[0].filePath)
WebViewer(
{
path: 'lib',
initialDoc: `lib/pdf/${pdfPath}`,
extension: "pdf"
},
viewer.current,
).then((instance) => {
const { docViewer, Annotations } = instance;
const annotManager = docViewer.getAnnotationManager();
docViewer.on('documentLoaded', () => {
const rectangleAnnot = new Annotations.RectangleAnnotation();
rectangleAnnot.PageNumber = 1;
// values are in page coordinates with (0, 0) in the top left
rectangleAnnot.X = 100;
rectangleAnnot.Y = 150;
rectangleAnnot.Width = 200;
rectangleAnnot.Height = 50;
rectangleAnnot.Author = annotManager.getCurrentUser();
annotManager.addAnnotation(rectangleAnnot);
// need to draw the annotation otherwise it won't show up until the page is refreshed
annotManager.redrawAnnotation(rectangleAnnot);
});
});
}
I'm thinking is because the ref component didn't receive in time the pdfPath state and then throw the error. I've tried to place a separate button to load the pdf with the pdfPath correctly updated and in that case worked. What can i do make it render correctly there?
this is the error I get from the console:
(index)
Value
UI version "7.3.0"
Core version "7.3.0"
Build "Mi8yMi8yMDIxfDZmZmNhOTdmMQ=="
WebViewer Server false
Full API false
Object
CoreControls.js:189 Could not use incremental download for url /lib/pdf/. Reason: The file is not linearized.
CoreControls.js:189
{message: "The file is not linearized."}
CoreControls.js:189 There may be some degradation of performance. Your server has not been configured to serve .gz. and .br. files with the expected Content-Encoding. See http://www.pdftron.com/kb_content_encoding for instructions on how to resolve this.
CoreControls.js:189 There may be some degradation of performance. Your server has not been configured to serve .gz. and .br. files with the expected Content-Encoding. See http://www.pdftron.com/kb_content_encoding for instructions on how to resolve this.
CoreControls.js:189 There may be some degradation of performance. Your server has not been configured to serve .gz. and .br. files with the expected Content-Encoding. See http://www.pdftron.com/kb_content_encoding for instructions on how to resolve this.
81150ece-4c18-41b0-b551-b92f332bd17f:1
81150ece-4c18-41b0-b551-b92f332bd17f:1 PDFNet is running in demo mode.
81150ece-4c18-41b0-b551-b92f332bd17f:1 Permission: read
CoreControls.js:922 Uncaught (in promise)
{message: "Exception: ↵ Message: PDF header not found. The f… Function : SkipHeader↵ Linenumber : 1139↵", type: "InvalidPDF"}
Thank you guys for any help I will get on this!
The value of "pdfPath" isn't set to "filteredDoc[0].filePath" yet after you call "setPdfPath" (it'll still be the initial state till the next render). One thing you can do is pass a callback function when using "setState" to call "WebViewer()" after "pdfPath" has been updated
https://reactjs.org/docs/react-component.html#setstate
Also there is a guide on how to add PDFtron to a React project in the following link
https://www.pdftron.com/documentation/web/get-started/react/
One thing to note, is it's does the following
useEffect(() => {
// will only run once
WebViewer()
}, [])
By doing the above, "WebViewer" is only initialized once. It might be a good idea to do something similar and use "loadDocument" (https://www.pdftron.com/documentation/web/guides/best-practices/#loading-documents-with-loaddocument) when switching between documents instead of reinitializing WebViewer each time the state changes

Using DomPDF in Cakephp Delivers an error Cannot redeclare class Dompdf\View\PdfView

I have a problem printing a PDF using CakePHP and DomPDF as soon I want to fetch some data from the Database before printing the pdf. Without fetching the Data, it works like a charme. My function is the following:
public function tourpdf($tourid = null){
$contain = ['Deliveries','Deliveries.Articletransactions','Deliveries.Orders','Deliveries.Orders.Customers',
'Deliveries.Articletransactions.Orderarticles','Deliveries.Articletransactions.Orderarticles.Articles'];
$tour = $this->Tours->get($tourid)
->contain($contain);
$this->viewBuilder()
->className('Dompdf.Pdf')
->layout('Dompdf.default')
->options(['config' => [
'filename' => $filename,
'render' => 'browser',
'size' => 'A4',
'orientation' => 'landscape'
]]);
$this->set('Test', 'Hallo');
$this->set('Tour',$tour);
}
As soon as I set the Data from the last line, that I fetched above, I get the error Message "Fatal error: Cannot redeclare class Dompdf\View\PdfView in .../src/View/PdfView.php on line 66".
However commenting the last line out, the first set with Test is working and the PDF is generated. How can I set data retrieving from a query to the pdf file?
I got a similar error, but with Zend Framework 2. All of a sudden DOMPDF would give an error "Cannot redeclare (previously declared in ...)".
I had PHP functions in some templates and when I removed them I was getting another error "No block-level parent found. Not good.". I noticed this started happening when I upgraded libxml2 from 2.9.4 to 2.9.5 or later.
The solution to both of the problems was to instantiate DOMPDF class like this:
use Dompdf\Options;
$options = new Options();
$options->set('enable_html5_parser', true);
$dompdf = new Dompdf($options);
With enable_html5_parser all the problems went away. Here is some more information on this issue.
Amazing!
Had this issue on Mac 10.12.6
PHP Version 5.6.30
libxml Version 2.9.4
Using the regex to remove whitespace between the tags fixed the issue.
$html = preg_replace('/>\s+</', '><', $html);

HostListener and Angular Universal

I'm trying to listen to a MessageEvent sent with postMessage in my Angular 2 component.
My first attempt was simply doing:
window.addEventListener("message", this.handlePostMessage.bind(this));
And then in ngOnDestroy:
window.removeEventListener("message", this.handlePostMessage.bind(this));
However this didn't work as expected. If I navigated to another route and back, there would be two event listeners registered.
So instead I've been trying to decorate the method with HostListener, but I can't get this working when using prerendering (Angular Universal with .NET Core using the asp-prerender-module).
#HostListener('window:message', ['$event'])
private handlePostMessage(msg: MessageEvent) {
...
}
That gives me the following error on page load:
Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: MessageEvent is not defined
Is there a workaround for this?
You're getting this error because MessageEvent is not defined. You must import whatever file defines this.
My #HostListeners look like this:
#HostListener("window:savePDF", ["$event"]) savePDF(event) {
this.savePDFButtonPushed();
}
and you can read more about them here:
https://angular.io/guide/attribute-directives
However, I'm currently experiencing the same issue you are -- that if I navigate to another route and back, I now receive two events. And that is using #HostListener. :-( However I haven't upgraded Angular in a while (currently using 4.4.6), so maybe they've fixed it since that release.
**Edit: Just upgraded to Angular 5.1.0. The 'duplicate events' #HostListener issue remains. :-(
Edit #2: I tried also using window.addEventListener like you tried, and also had the same issue, despite using window.removeEventListener in ngOnDestroy().
This lead me to dig a little deeper, where I found some code I had added to listen to messages from a child iFrame. Any chance you have something similar in your code?
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen to messages from child window ("unsign" and "savePDF") and pass those along as events to Angular can pick them up in its context
eventer(messageEvent,function(e) {
window.dispatchEvent( new Event( e.data ) );
},false);
This had been in my page's constructor. I protected it so it only executed the first time the page was constructor, and now all is well.

Sencha Touch - Can't use destroy method

I can't destroy a navigationView, when I try, receive the following error:
"Uncaught TypeError: Cannot read property 'getScroller' of undefined "
I don't understand, when I load on Chrome browser don't receive any error message, but when put in production mode the problem appears.
I'm trying to destroy like this:
finalizaJanela: function()
{
Ext.getCmp('buscacli').destroy();
var page2 = Ext.Viewport.add(Ext.create('Android.view.CadClientes'));
Ext.Viewport.setActiveItem(page2);
},
Someone knows how to solve?

Extjs - cant load content to panel

I created Extjs.Panel and now I would like to dynamically load a content to it. So I wrote this simple code
Ext.get('contentPanel').load({
url: '#Url.Action("TempView","Home")'
});
After executing this function, panel is populated with TempView, however couple of seconds later I get an error in Extjs library
Microsoft JScript runtime error:Unable to get value of the property
'events': object is null or undefined.
EDIT
I flollowed #DmitryB advice and I used debug version of library. Here is what I found out. It turned out that the problem is in function
getElementEventCache
which is defined in file ext-all-debug.js in line 11108. The function looks this way
getElementEventCache : function(element) {
if (!element) {
return {};
}
var elementCache = Ext.cache[this.getId(element)];
return elementCache.events || (elementCache.events = {});
},
The exception is thrown in the last line, because of the fact that elementCache is null.
Here is the stacktrace from visualstudio
I had a very similar error that was resolved by adding the following line. (from this forum thread)
if(Ext.isIE) {
Ext.enableGarbageCollector=false;
}
I'm using bellow code and work cool. This may help you.
Try this
var content_div = Ext.get(div_id);
content_div.load({
url:your_url,params:{id:'abc'},scripts:true,text: 'Loading...'});
content_div.show();

Resources