NYCPHP Meetup

[nycphp-talk] OT - PHP portlet in Java's Liferay portal

Néstor rotsen at gmail.com
Tue Mar 4 11:51:01 EST 2008


Brian,

I actually set the 'Content-Type' to 'image/png' and 'image/x-png' while
testing and realized that
the '<IMG>' tag took care of the content type weather it was set to
test/html or image/png.

Why am I using PHP and Java.  Liferay is a Java Portal and it is very good,
I do not know of
something like it written in PHP.  Liferay allows you to create portlets
using the
QUERCUS tecnology, which converts PHP code to Java byte code.

I have created a couple of portlets and they work.  My problem at this
moment is that the portlet
I have develop works to the point that the pie chart file is created as a
PNG but I am having problem
displaying it as a graph and it displays as binary.  The php file works if I
run it from my apache server
but it displays binary if I run it from within the Liferay portal.

Thanks,

Nestor :-)

On Tue, Mar 4, 2008 at 6:12 AM, Brian D. <brian at realm3.com> wrote:

> Why are you using JSP (Java servlet pages) alongside PHP?
>
> Either way, your problem is probably related to not sending headers
> along with the image. If you're generating the chart, make sure it's
> sending mime-type (Content-type) headers before sending the binary PNG
> data. Otherwise the browser doesn't know what it's receiving and it
> will garble it.
>
> It's been a couple of years since I've written Java applications, but
> the relevant PHP function is here:
> http://us3.php.net/header
> Take a look at Example #1.
>
> - Brian
>
> On Tue, Mar 4, 2008 at 2:43 AM, Néstor <rotsen at gmail.com> wrote:
> >  I am in need of help. I have created a chart PHP portlet and I am able
> to
> > deploy. The problem is that the PNG image file
> > displays as binary. I know that the file is created and is there and I
> can
> > open it with my browser and it displays the Pie chart
> >
> > My php code:
> > <html xmlns="http://www.w3.org/1999/xhtml">
> > <head>
> >  <title>Libchart pie chart demonstration</title>
> >  <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-15" />
> > </head>
> > <body>
> >  <img alt="Pie chart" src="<%=renderRequest.getContextPath()%>/demo3.png"
> />
> >  </body>
> > </html>
> >
> > I read in some articles that you need to use the jsp code
> > <%=renderRequest.getContextPath()%>
> > but is not working. I also try it without the JSP code and I get the
> same
> > result.
> >
> > This is what is displayed
> > -----------------
> > �PNG ��� IHDR�� X���� ����O�G�� ]IDATx���}�U��� ��pI��]�" ���KE"
> > l*Y�X�T�&Z�BL� ����E;� !m�1�HcT ���n0 Q�� ��M6��d��5�Y ���R
> > l�p��͝q�3s�s�s��''f� 3�� ���wϝ�? @�z�'�@ @ @ @ ?u��� ��
> > 8x���.��ǧ�Zv�sN<�kSf_z޲�M�_ �s��7�����M����=a���#�0�������s� �7/ !��
> > �eW��I3>M�䙋��v��g�ye� �ݷ T!���Y�`L 3����O�� �m��p�!< �o4*8��l�m; �� ���
> > >�`�ĉB @5B8����� �M�7=��㢟
> > <A bunch of other stufff and then the last part of what it is displayed>
> > ��!�H �1{�m� va2�����" g# B��� ag'�̋�O��Z �l� �u� KZ 3,b �Kp �� � �
> > #,o5̧���_��`�� �0�����0�(�2~)ρ�6B �\6�h�a]�X��? � �FX��fQ�G� � �FX��
> Q�A�*�
> > � �FX���u�h� � �F��vX�4V�yU� m�`#�n;�D �]��@ !� �� � �v�N�٫� h#
> ��0�#����
> > (�`#4 a�'@ !� -�B���g# � Q ���l�`#4" a�� l��D!�w� ��Р(���~6B� � s �ۃ�
> > l���*���6B� RՉ��g# !� f�2Z�l� �6¬ HÞ� ��F 6B B !� A m�`# !� �� ��F 6B B
> !�
> > �F � �F � �F � �F � �F � �F � ��! �� $ � ��� ���Y� ! !�R @ @ @ @ @ @ @ @
> @ @
> > @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ B� B� B�
> B��ȟ��9��(e�����IEND�B`�
> > Pie chart
> > document.getElementById
> ("p_p_id_libchartportlet_WAR_libchartportlet_").portletId
> > = "libchartportlet_WAR_libchartportlet";
> > document.getElementById
> ("p_p_id_libchartportlet_WAR_libchartportlet_").columnPos
> > = 5; if (!Liferay.Portlet.isAjax("libchartportlet_WAR_libchartportlet"))
> {
> > Liferay.Portlet.process("libchartportlet_WAR_libchartportlet"); }
> jQuery(
> > function() { Liferay.Util.portletTitleEdit( { obj:
> > jQuery("#p_p_id_libchartportlet_WAR_libchartportlet_"), plid: "10133",
> > doAsUserId: "", portletId: "libchartportlet_WAR_libchartportlet" } ); }
> );
> > -----------------
> >
> > I do not get all of the the javascript stuff after "Pie chart" above if
> I do
> > not use the JSP code.
> >
> >
> > Any ideas of what is wrong with my PHP displaying of the PNG file.
> >
> > Thanks,
> >
> > rotseN
> > _______________________________________________
> >  New York PHP Community Talk Mailing List
> >  http://lists.nyphp.org/mailman/listinfo/talk
> >
> >  NYPHPCon 2006 Presentations Online
> >  http://www.nyphpcon.com
> >
> >  Show Your Participation in New York PHP
> >  http://www.nyphp.org/show_participation.php
> >
>
>
>
> --
> realm3 web applications [realm3.com]
> freelance consulting, application development
> (917) 512-3594
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080304/75bb5ea6/attachment.html>


More information about the talk mailing list