You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ilia <il...@gmail.com> on 2016/03/01 12:09:33 UTC

How get path html page

Hello!
I have the following object
NamePanel.class
NamePanel.html
NamePage.class
NamePage.html
Onclick button I need to get the path of the page for further conversion
html to pdf
buttonSave.add(new AjaxEventBehavior("onclick") {
            @Override
            protected void onEvent(final AjaxRequestTarget target) {
                String path = target.getPage().getPageRelativePath(); 
                new FileInputStream(path);
                        
}
        });

>new FileInputStream(path);
Method threw 'java.io.FileNotFoundException' exception.

Please help me.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Ilia <il...@gmail.com>.
As I said earlier: when I take a simple html page- working generated html to
PDF.
If it did not work on a simple page html - I was looking for the cause of
the other problem.
My html page contains table and from this page generated PDF file.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673813.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
Check what is the difference between your simple HTML page that works and
the one generated by Wicket.
Save the one generated by ComponentRenderer in a file and modify it until
it becomes valid for the PDFcreator. Then see how to improve your Wicket
HTML templates.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Mar 3, 2016 at 11:39 AM, Ilia <il...@gmail.com> wrote:

> Hi,
>
> My html page contains table and from this page generated PDF file.
> I checked the code on a simple html page - PDF generated and open no
> problem. My code working. But when I checked the code on a wicket html page
> PDF file not open.
>
> How to ensure the correct generating proper XHTML?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673814.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How get path html page

Posted by Ilia <il...@gmail.com>.
Hi,

My html page contains table and from this page generated PDF file.
I checked the code on a simple html page - PDF generated and open no
problem. My code working. But when I checked the code on a wicket html page
PDF file not open.

How to ensure the correct generating proper XHTML?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673814.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
and make sure you are generating proper XHTML.

On Thu, Mar 3, 2016 at 10:01 AM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> On Thu, Mar 3, 2016 at 9:30 AM, Ilia <il...@gmail.com> wrote:
>
> > Hi,
> > Implements this code, I get following logic
> >
> > Class componentClass = page.getPage().getClass();
> > PageProvider pageProvider = new PageProvider(componentClass,
> > page.getPageParameters());
> > StringBuilder finalPageHtml = (StringBuilder)
> > ComponentRenderer.renderPage(pageProvider);
> > InputStream arrayInputStream = new
> > ByteArrayInputStream(finalPageHtml.toString().getBytes());
> > XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
> > arrayInputStream);
> >
> > !!!Attention!!!
> > When you execute the code -
> > XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
> > arrayInputStream);
> > I get exception: java.lang.ClassCastException: Insertion of illegal
> > Element:
> > 15
> >
>
> As I said earlier: This is not Wicket related question! Please consult with
> the documentation of your PDF creation library and/or contact their forums.
>
>
> >
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673810.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Thu, Mar 3, 2016 at 9:30 AM, Ilia <il...@gmail.com> wrote:

> Hi,
> Implements this code, I get following logic
>
> Class componentClass = page.getPage().getClass();
> PageProvider pageProvider = new PageProvider(componentClass,
> page.getPageParameters());
> StringBuilder finalPageHtml = (StringBuilder)
> ComponentRenderer.renderPage(pageProvider);
> InputStream arrayInputStream = new
> ByteArrayInputStream(finalPageHtml.toString().getBytes());
> XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
> arrayInputStream);
>
> !!!Attention!!!
> When you execute the code -
> XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
> arrayInputStream);
> I get exception: java.lang.ClassCastException: Insertion of illegal
> Element:
> 15
>

As I said earlier: This is not Wicket related question! Please consult with
the documentation of your PDF creation library and/or contact their forums.


>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673810.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How get path html page

Posted by Ilia <il...@gmail.com>.
Hi,
Implements this code, I get following logic

Class componentClass = page.getPage().getClass();
PageProvider pageProvider = new PageProvider(componentClass,
page.getPageParameters());
StringBuilder finalPageHtml = (StringBuilder)
ComponentRenderer.renderPage(pageProvider);
InputStream arrayInputStream = new
ByteArrayInputStream(finalPageHtml.toString().getBytes());
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
arrayInputStream);

!!!Attention!!!
When you execute the code - 
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document,
arrayInputStream);
I get exception: java.lang.ClassCastException: Insertion of illegal Element:
15


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673810.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You need something like:

String finalPageHtml = ComponentRenderer.renderPage(pageInstance);
InputStream htmlStream = new ByteArrayInputStream(finalPageHtml.getBytes(),
"UTF-8");
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document, htmlStream);

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Mar 1, 2016 at 5:51 PM, Ilia <il...@gmail.com> wrote:

> Ok, my old code. This code working for SIMPLE html page but not work for
> wicket html page :
>
> Document document = new Document();
>                     PdfWriter pdfWriter = PdfWriter.getInstance(document,
> new FileOutputStream(fc.getSelectedFile() + ".pdf"));
>                     document.open();
>                     Class componentClass = page.getPage().getClass();
>                     InputStream htmlStream =
> componentClass.getResourceAsStream(componentClass .getSimpleName() +
> ".html");
>                     XMLWorkerHelper.getInstance().parseXHtml(pdfWriter,
> document, htmlStream);
>
>
> How RIGHT apply ComponentRenderer. render Page(yourPageInstance) and
> convert
> the result
> to PDF ???
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673788.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How get path html page

Posted by Ilia <il...@gmail.com>.
Ok, my old code. This code working for SIMPLE html page but not work for
wicket html page :

Document document = new Document();
                    PdfWriter pdfWriter = PdfWriter.getInstance(document,
new FileOutputStream(fc.getSelectedFile() + ".pdf"));
                    document.open();                    
                    Class componentClass = page.getPage().getClass();
                    InputStream htmlStream =                           
componentClass.getResourceAsStream(componentClass .getSimpleName() +
".html");
                    XMLWorkerHelper.getInstance().parseXHtml(pdfWriter,
document, htmlStream);


How RIGHT apply ComponentRenderer. render Page(yourPageInstance) and convert
the result 
to PDF ???


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673788.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
OK, I think I see your problem.
You pasted the raw HTML templates.
You need to generate the PDF from the rendered page.
Use ComponentRenderer.renderPage(yourPageInstance) and convert the result
to PDF.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Mar 1, 2016 at 1:16 PM, Ilia <il...@gmail.com> wrote:

> Ok, the example of a simple html page works good and created *.pdf file
> open
> no problems.
> When I make an example html page wicket I get error: file is corrupt or in
> an unsupported format.
>
> Example code html page NamePage.html:
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:wicket="http://wicket.apache.org">
> <wicket:extend>
>     span wicket:id="NamePanel"/>
> </wicket:extend>
> </html>
>
> Ecample code html page NamePanel.html
> <html xmlns:wicket="http://wicket.apache.org/"
> xmlns="http://www.w3.org/1999/html">
> <head>
>     <script type="text/javascript"
> src='/templates/registratorTemplate/js/jquery.min.js'/>
> </head>
> <body>
> <wicket:panel>
>     <article class="module width_full">
>         <header>
>
>
>                 <wicket:message key="statistics.client.service"/>
>                 span wicket:id="date">
>
>
>         </header>
>
>
>
>
>
>
>                     <wicket:message key="service"/>
>
>
>                     <wicket:message key="statistics.client.service.date"/>
>
>
>                     <wicket:message
> key="statistics.client.service.result.all"/>
>
>
>
>
>
>                 span wicket:id="dateReport">
>
>
>
>
>
>
>
>
>                     span class="table" wicket:id="serviceName">
>
>
>
>                     span wicket:id="countClientPlaces">
>
>
>
>                     span class="table" wicket:id="sumAllResult">
>
>
>
>
>
>
>                     <wicket:message
> key="statistics.client.service.result"/>
>
>
>                     span class="table" wicket:id="sumResult">
>
>
>
>                     span class="table" wicket:id="sum">
>
>
>
>
>
>
>         <footer>
>             <div class="submit_link">
>                 <input wicket:message="value:button.submit"
> wicket:id="saveReport" type="submit" value="Submit"/>
>             </div>
>         </footer>
>     </article>
> </wicket:panel>
> </body>
> </html>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673774.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How get path html page

Posted by Ilia <il...@gmail.com>.
Ok, the example of a simple html page works good and created *.pdf file open
no problems.
When I make an example html page wicket I get error: file is corrupt or in
an unsupported format.

Example code html page NamePage.html:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org">
<wicket:extend>
    span wicket:id="NamePanel"/>
</wicket:extend>
</html>

Ecample code html page NamePanel.html
<html xmlns:wicket="http://wicket.apache.org/"
xmlns="http://www.w3.org/1999/html">
<head>
    <script type="text/javascript"
src='/templates/registratorTemplate/js/jquery.min.js'/>
</head>
<body>
<wicket:panel>
    <article class="module width_full">
        <header>
            

                <wicket:message key="statistics.client.service"/>
                span wicket:id="date">
            

        </header>
        

            
            

                	
                    <wicket:message key="service"/>
                
                	
                    <wicket:message key="statistics.client.service.date"/>
                
                	
                    <wicket:message
key="statistics.client.service.result.all"/>
                
            
            

                	
                span wicket:id="dateReport">
                
                
            
            
            
            

                	
                    span class="table" wicket:id="serviceName">
                    
                
                	
                    span wicket:id="countClientPlaces">
                    
                
                	
                    span class="table" wicket:id="sumAllResult">
                    
                
            
            

                	
                    <wicket:message key="statistics.client.service.result"/>
                
                	
                    span class="table" wicket:id="sumResult">
                    
                
                	
                    span class="table" wicket:id="sum">
                    
                
            
            
        

        <footer>
            <div class="submit_link">
                <input wicket:message="value:button.submit"
wicket:id="saveReport" type="submit" value="Submit"/>
            </div>
        </footer>
    </article>
</wicket:panel>
</body>
</html>

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673774.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
Well, this is an application problem.
You have to debug it.
Start by trying to open this PDF file in a PDF viewer.

Don't hesitate to come back to us if you have Wicket related problem!


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Mar 1, 2016 at 12:45 PM, Ilia <il...@gmail.com> wrote:

> Thanks but now don't open created *.pdf
> error:
> file is corrupt or in an unsupported format
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673771.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How get path html page

Posted by Ilia <il...@gmail.com>.
Thanks but now don't open created *.pdf
error:
file is corrupt or in an unsupported format

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768p4673771.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How get path html page

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You can use:
Class componentClass = component.getClass();
InputStream htmlStream =
componentClass.getResourceAsStream(componentClass.getSimpleName() +
".html");


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Mar 1, 2016 at 12:09 PM, Ilia <il...@gmail.com> wrote:

> Hello!
> I have the following object
> NamePanel.class
> NamePanel.html
> NamePage.class
> NamePage.html
> Onclick button I need to get the path of the page for further conversion
> html to pdf
> buttonSave.add(new AjaxEventBehavior("onclick") {
>             @Override
>             protected void onEvent(final AjaxRequestTarget target) {
>                 String path = target.getPage().getPageRelativePath();
>                 new FileInputStream(path);
>
> }
>         });
>
> >new FileInputStream(path);
> Method threw 'java.io.FileNotFoundException' exception.
>
> Please help me.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-get-path-html-page-tp4673768.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>