I am getting the path of HTML file from IFile-
The method is like -
public IStatus runCustomizer(final IFile file, final IDOMPosition position)
{}
Through this IFile, I am getting an HTML file. Now I want to modify the html file.
I'm not sure the question is restricted with Eclipse. You can read file into any DOM presentation e.g. JDom, Saxon, Xerces etc. and perform XSLT transformation on it. This way is most common but heavy. You can perform customization on DOM presentation manually. These ways are acceptable only if your html file is well-formed. If no you can work with it like with text file but this is more error prone approach.
Related
When we take a pathfield value in jsp, need to provide harcoded ".html" or ".pdf".
Is there any way to make pathfield generic, hence no need to provide hard coded extensions? So if a user selects .pdf it will display a pdf file and if user selects .html it will open a html file.
Not sure if there is a OOB way to do this. Alternatively, You can create a script/custom jstl tag which take path as input, load resource and find out resource type and generate path with correct extn as output.
Call this script from all your components which generate links.
Another option is you extend com.day.cq.rewriter.pipeline.RequestRewriter and in rewriteLink() function write your logic to set correct extn.
I have a CSS file that is in the same view/scripts folder as the phtml file that will use it. What is the correct parameter for $this->headLink()->appendStylesheet() for such a file?
Your css file must be accessible in public directory or public subdirectory like public/css/your_css_file.css
In your view, you can do something like this:
$this->headLink()->appendStylesheet($this->baseUrl() .'/css/your_css_file.css');
Normally your CSS file should be accessible publicly (within the public folder).
However, if you still want to leave it there (you will have performance issues especially if your file is large) just do so within your view file
<?php
$this->headStyle()->captureStart();
echo $this->partial('css-file.css');
$this->headStyle()->captureEnd();
?>
This will allow your file contents to be output, captured and then "injected" in the appropriate place in the layout.
Hope it helps
In my mark-up I want to add a space ( ) between elements without always having to use CSS to do so. If I put in my markup, GWT throws errors. Is there a way around it?
For example:
<g:Label>One </g:Label><g:Label>Two</g:Label>
Should show:
One Two
And not:
OneTwo
As documented here, you just have to add this to the top of your XML file and it will work!
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
Note that the GWT compiler won't actually visit this URL to fetch the file, because a copy of it is baked into the compiler. However, your IDE may fetch it.
Rather than use a Label, which to me shouldn't allow character entities at all, I use an HTML widget. In order to set the content, though, I find I have to do it as the HTML attribute, not the body content (note that the uppercase HTML is important here, since the set method is setHTML, not setHtml)
<g:HTML HTML="One " />
I have some simple GWT client code that I would like to test using GWTTestCase and GWTTestSuite.
However, those tests require the use of some CSS stylesheet (only needed for the tests).
My first attempt was :
Define a ClientBundle that provide the CSS file used for tests.
in my gwtSetUp(), call the `ensureInjected() method to add the CSS file before my tests get called
Test if the CSS style was applied to a particular element in the DOM, for example
code:
assertEquals("blue", element.getStyle().getBorderColor());
I got no errors, but this not seems to work.
Looking throught the logs of the Console (during the Junit test) I found this :
Initializing ResourceGenerator
Finding operable CssResource subtypes
Computing CSS class replacements
Preparing method css
Finding resources
Parsing CSS stylesheet file:/D:/Workspace/libraries/gwt-text/gwt-text/src/test/java/com/t/i/client/CSSDecorationTest.css
Scanning CSS for requirements
Creating fields
Creating assignment for css()
Creating image sprite classes
Replacing property-based #if blocks
Replacing CSS class names
Performing substitution in node border-color : ..... ;
My css file simple contains :
.d {
border-color: blue;
}
EDIT
Please see this link : https://stackoverflow.com/a/10575244/921244
This was the wrong approach as getStyle do not provide the CSS computed style. Too bad.
If you don't need to do anything special with your CSS (i.e. it's a simple CSS, not a CssResource), then you could simply create a GWT module (gwt.xml file) dedicated for your tests (make it <inherits> your module-under-test and have your GWTTestCase's getModuleName return the name of the test-specific module instead of the module-under-test) in which you'd add a <stylesheet src="…" /> to include your stylesheet (simplest way if the stylesheet is only to be used for tests, put it in a public subfolder next to the test-specific gwt.xml file).
See https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideAutomaticResourceInclusion
Alternatively, using CssResource as you did, you might want to call StyleInjector.flush() just after your call to ensureInjected().
In my project we are using dojo framework in UI. We are having a functionality to exporting the data in the enhanced grid into excel/csv files. In the dojo toolkit, they are binding the id in the textarea but i need those values in the excel/csv file...can any one help in this issue...? if possible pls tell me how to export the enhanced grid data to excel/csv files...
If you are already using the Enhanced Data Grid, you should be able to include the exporter plugin - dojox.grid.enhanced.plugins.exporter.CSVWriter - to get the CSV text.
This will give you access to two main functions exportGrid and exportSelected that will take the contents and export them as CSV text.
Unfortunately that doesn't get them as a separate file (click to download), just the formatted text in a textarea (or whatever).
To get a "click to download CSV function), you could write a servlet/jsp proxy, which would take a POST from your page with the CSV text (from the plugin above) as part of the form and simply copy it back out with the correct headers to make it appear as an attachment.
response.setContentType("text/csv"); response.setHeader("Content-Disposition","attatchment;filename=name.csv")
This would require something server side though.. and at that point, you may want to consider having a servlet simply produce the CSV text directly.
http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid/plugins/Exporter.html