Tabulator - How to refresh table from json file - tabulator

I am trying to update my Tabulator table from a JSON file. When an item is submitted or deleted, it triggers a PHP file that updates the file fine. However, the table does not update. If I hard reload the page (CTRL+F5), the table updates correctly. Otherwise, it will not update with a regular reload. I have a location.refresh(); in my code for deleting with a successful ajax request to my PHP file. My PHP files have a "Refresh:0; url = tabulator.html". I have tried adding to the top of my html page:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
and to the top of my PHP file:
header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0');
At the end of my table creation i have table.setData(); since I use an ajaxURL to load the data in the table. Anyone have any idea how I can refresh the table with the data from the JSON file when an item is submitted or deleted? Thanks in advance.

use reactiveData:true, //enable reactive data
checkc documentation

Related

Single page with Astro and Netlify CMS

I’m trying to create a Single page with astro and netlify cms, in which the admin should be able to add/remove/modify the page through /admin, but I’m struggling with the understanding of the folder structure.
So, as far as I know, I need to specify the collection structure in the config.yml file. Something like this. (see attached file)
Which will create a content.md file. Basically it will contain all the info that was created through /admin.
The problem is that I don’t know how and where this content.md file is used. Should I import it manually in the index.astro file or am I wrong?
Thank you in advance 🙂
If you have a Markdown file at src/content/content.md, you will need to import and render it somewhere. It depends which page you want to display this content on, but if you want to show the content on your homepage, this would be src/pages/index.astro.
Here’s an example:
---
// src/pages/index.astro
import { Content, frontmatter } from '../content/content.md';
---
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My homepage</title>
</head>
<body>
<h1>{frontmatter.title}</h1>
<article>
<Content /> <!-- this will render your Markdown body -->
</article>
</body>
</html>
The key things to note here are:
The use of the <Content /> component to render the main Markdown content of your Markdown file
The use of an expression {frontmatter.title} to access the title field from your Netlify CMS config. Other fields would be available in the same way: {frontmatter.description}, {frontmatter.heroImage} etc.

render html from string without affecting formatting [duplicate]

Is there any way to setup Firefox and Chrome to work with escape=false attribute in h:outputText tag. When there is some html that needs to be shown in the browser, Firefox and Chrome show parsed string correctly, but any other links in application are freezed (??).
The example html from db:
<HEAD>
<BASE href="http://"><META content="text/html; charset=utf-8" http-equiv=Content-Type>
<LINK rel=stylesheet type=text/css href=""><META name=GENERATOR content="MSHTML 9.00.8112.16434">
</HEAD>
<BODY><FONT color=#000000 size=2 face="Segoe UI">läuft nicht</FONT></BODY>
Parsed HTML on the page:
läuft nicht
What is very weird, is that in IE everything works (usually it is opposite).
I use primefaces components (v2.2), .xhtml, tomcat 7 and JSF 2.0
You end up with syntactically invalid HTML this way:
<html>
<head></head>
<body>
<head></head>
<body>...</body>
</body>
</html>
This is not right. There can be only one <head> and <body>. The browsers will behave unspecified. You need to remove the entire <head> and the wrapping <body> from that HTML so that you end up with only
<FONT color=#000000 size=2 face="Segoe UI">läuft nicht</FONT>
You'd need to either update the DB to remove unnecessary HTML, or to use Jsoup to parse this piece out on a per-request basis something like as follows:
String bodyContent = Jsoup.parse(htmlFromDB).body().html();
// ...
Alternatively, you could also display it inside a HTML <iframe> instead with help of a servlet. E.g.
<iframe src="htmlFromDBServlet?id=123"></iframe>
Unrelated to the concrete problem:
Storing HTML in a DB is a terrible design.
If the HTML originates from user-controlled input, you've a huge XSS attack hole this way.
The <font> tag is deprecated since 1998.
It seems to me that you're trying to do something that JSF was not really meant to do. Rather than try to insert HTML in your web page, you ought to try having the links already on your page and modifying the "rendered" attribute through an AJAX call.

debugger info & issues

complete HTML virgin 3 weeks ago but have managed to stumble along and get my site up and running to an ok standard but im having problems with fb intergration, fb like looks like it should, comments posting as they should but on debug i get the following....
Scrape Information
Response Code 200
Fetched URL http://shropshireradio.com/
Canonical URL http://ShropshireRadio.com/
Object Properties
fb:app_id 149188391870835
og:url http://ShropshireRadio.com/
og:type website
og:title Streaming Shropshire DJs
og:image
og:description music of all genres under 1 roof
og:updated_time 1331952439
Raw Open Graph Document Information
Meta Tag <meta property="fb:app_id" content="149188391870835" />
Meta Tag <meta property="og:type" content="website" />
Meta Tag <meta property="og:url" content="http://ShropshireRadio.com" />
Meta Tag <meta property="og:title" content="Streaming Shropshire DJs" />
Meta Tag <meta property="og:description" content="music of all genres under 1 roof" />
Meta Tag <meta property="og:image" content="http://i1067.photobucket.com/albums/u437/ShropshireRadio/ShropshireRadio.jpg" />
Redirect Path
original http://shropshireradio.com/
og:url http://ShropshireRadio.com/
Final URL is in bold (this is the URL we tried to extract metadata from).
I can see above that it doesnt look right but cant match it up to my code to see whats wrong!! any help appreciated!! Cheers
I've had to change 2 urls fetched and cononical to post this in my script it is correct
The content attribute for the meta tag with property "og:type" should be something from this list currently you have it as the url for your site.
the prefix attribute of your head tag should be this
og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# website: http://ogp.me/ns/website#
also, you should change the data-href attribute of your fb:like tag from http://www.facebook.com/ShropshireRadio.comTeam to http://shropshireradio.com/

Htaccess html file from being indexed

Hey we are trying to prevent just one file from being indexed by google. "preview.html"
How can we set this up to allow everything else but deny this one html file?
<meta name="robots" content="noindex">

How to make a meta tag the first one in the <head> section?

I'm using JSF2, GlassFish 3.1, PrimeFaces 2.x.
I'm having strange rendering problems on IE9. I'm supposed to be able to force IE9 to render as IE9 by inserting the following:
<html>
<head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
...
But the thing is, it's not working because (I'm told) the meta tag MUST be the first tag in the section.
When I do this in my XHTML file ...
<html ...>
<f:view contentType="text/html" locale="#{loginHandler.currentLocale}">
<h:head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
The resulting HTML looks like this, where JSF/PrimeFaces has inserted a bunch of "link" and "script" tags before my new meta tag.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.css.jsf?ln=primefaces&v=2.2" />
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/wijmo/wijmo.css.jsf?ln=primefaces&v=2.2" />
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=2.2"></script>
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.js.jsf?ln=primefaces&v=2.2"></script>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />
Is there any way to get my meta tag in the right place so it will work? (Or an alternative way to make this IE9 problem go away?
The meta tag must go before all PrimeFaces stuff:
http://blogs.msdn.com/b/cjacks/archive/2012/02/29/using-x-ua-compatible-to-create-durable-enterprise-web-applications.aspx
HTTP Header and HTML HEAD are completly different things.
In PrimeFaces 3.0 the new facet was added to h:head:
http://blog.primefaces.org/?p=1433
So the solution would be:
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
</f:facet>
</h:head>
I think best solution is to create JSF PhaseListener which adds X-UA-Compatible header to HTTP response
public class UACompatibleHeaderPhaseListener implements PhaseListener {
private static final long serialVersionUID = 1L;
#Override
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
#Override
public void beforePhase(PhaseEvent event) {
final FacesContext facesContext = event.getFacesContext();
final HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("X-UA-Compatible", "IE=edge");
}
#Override
public void afterPhase(PhaseEvent event) {
}
}
and register it in faces-config.xml
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" version="2.0">
<lifecycle>
<phase-listener>com.example.UACompatibleHeaderPhaseListener</phase-listener>
</lifecycle>
</faces-config>
Another option would be to create servlet Filter and register it in web.xml.
Why is this needed?
Imagine your web application is deployed on a domain (or sub-domain) which is on IE compatibility list here: http://ie9cvlist.ie.microsoft.com/ie9CompatViewList.xml so you need to use X-UA-Compatible header to switch IE back to latest mode.
Imagine your web application is deployed on WebLogic server (which uses mojarra 2.0.4) so you cannot change JSF implementation.
mojarra
You can create Filter which adds header:
X-UA-Compatible: IE=9
to response object.
Source
Just to comment on your answer and previous comments:
HTTP Header and HTML Head are not completly different things (effectively) if you view page on IE8 as shown by diagram here. If you set HTTP header, but not HTML Head, the directive from HTTP header is still taken into account.
I don't know how IE9 behaves, but I guess that in a similar way.
You might want to switch from Mojarra to MyFaces. Looking at the source code of MyFaces' HEAD renderer - first gets rendered the content of the element and then other resources. Mojarra is doing this probably other way around. If you don't want to switch JSF implementations you can just implement your own HEAD element renderer.
However I would suggest just to find out why IE9 is not working without the X-UA-Compatible meta tag. It is supposed to make newer versions to behave like older versions.

Resources