You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Tim McGuire <tm...@go-integral.com> on 2007/03/07 20:37:40 UTC

image tag causing request to controller

Hello list,

I have a confusing error in which an image tag on an FTL page is
triggering a request that is being routed through the controller and
causing all of the associated events for that request to be executed
twice (or three times if there are two image tags).  I've been staring
at my controller.xml and my web.xml to discover why this is happening
and I can't see it. 

1) where can I set a debugging breakpoint to view the contents of the
request object before it hits the controller.
2) why is this happening in the first place?

here is the offending line in FTL page:
<IMG name="largeImage" src="" >  

here is part of web.xml:

 <filter>
        <filter-name>ContextFilter</filter-name>
        <display-name>ContextFilter</display-name>
 
<filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
        <init-param>
            <param-name>disableContextSecurity</param-name>
            <param-value>N</param-value>
        </init-param>
        <init-param>
            <param-name>allowedPaths</param-name>
            <param-value>
 
/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/imag
es:/scanjobs:/includes/maincss.css:/ImageServer</param-value>
        </init-param>
        <init-param>
            <param-name>errorCode</param-name>
            <param-value>403</param-value>
        </init-param>
        <init-param>
            <param-name>redirectPath</param-name>
            <param-value>/control/main</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>ContextFilter</filter-name>
            <url-pattern>/*</url-pattern>
    </filter-mapping>

here is part of controller (the mapping that is getting executed - it is
the populateMetadata method that gets executed more than once):
<request-map uri="updateMetadata">
        <security https="false" auth="true"/>
        <event type="java"
 
path="com.gointegral.opendm.scanstation.events.ScanstationEvents"
            invoke="populateMetadata"/>
        <response name="assetUploadSuccess" type="view"
value="updateMetadataSuccess"/>
        <response name="scanSuccess" type="view"
value="updateMetadataSuccess"/>
        <response name="error" type="view" value="error"/>
    </request-map>

Tim McGuire
Integral Business Solutions

RE: image tag causing request to controller

Posted by David Napolitan <dn...@alexanderinteractive.com>.
Phani,

> Will it be going into a infinate loop?

This should not cause any sort of loop situation as the second request
is for an "image" as far as the browser is concerned; it will not cause
the browser to refresh.   This will, as we've seen, potentially cause
services/events to run a second time.  Please note that, any POSTed
request params will be missing on the second request and most likely
cause this  second round of services to fail.

> From my experience with other
> MVC projects using struts i never had a problem, does our ofbiz
Architecture
> have a issue with this or is it in general ?

Well I think this is more of a browser/HTML issue.  With the given HTML,
this second request would happen regardless of any particular
server-side framework.

I'm not an HTML guru, but I'm not sure why one would want a blank src
attribute in an image tag in the first place.  We stumbled upon this as
a result of bad freemarker - it was not our intention to render html
like this.


-Dave

-----Original Message-----
From: G.Venkata Phanindra [mailto:phani1983@gmail.com] 
Sent: Friday, March 09, 2007 12:30 AM
To: user@ofbiz.apache.org
Subject: Re: image tag causing request to controller

Hi David and Others,
        Will it be going into a infinate loop? From my experience with
other
MVC projects using struts i never had a problem, does our ofbiz
Architecture
have a issue with this or is it in general ?

Regards
Phani

On 3/8/07, David Napolitan <dn...@alexanderinteractive.com> wrote:
>
> Hi,
>
> I was just looking into this same problem yesterday.  This is what I
> found:
>
> As you know, you will see this problem when you have an img tag with a
> blank or hashed value as the src attribute:
>
> <img src="#"/>  or <img src=""/>
>
> Since the src attribute doesn't start with a protocol, the browser
will
> interpret this as a relative url.  It appends this value (" " or "#")
to
> your current url when it goes to fetch this image.  As a result, it
> makes a request with a url matching that of your current page.  .. and
> you get these additional requests being made.
>
> I hope that helps.
>
> -Dave
>
>
>
> -----Original Message-----
> From: Tim McGuire [mailto:tmcguire@go-integral.com]
> Sent: Thursday, March 08, 2007 10:45 AM
> To: user@ofbiz.apache.org
> Subject: RE: image tag causing request to controller
>
> This behavior only happens when I give a blank src attribute  <img
> name="largeImage" src="">
> if I fill it in with garbage or delete it altogether, it works as
> expected.
>
>
> I've attached relevant portion of console.log
>
> the FTL file is pared down to a testing.ftl:
>
> <TABLE border=0 width='100%' cellspacing='0' cellpadding='0'
> class='boxoutside'>
>   <TR>
>     <TD width='100%'>
>       <table width='100%' border='0' cellspacing='0' cellpadding='0'
> class='boxtop'>
>         <tr>
>           <td width="100%"><div class="boxhead">TESTTESTTESTTESTTEST
> </div></td>
>
>         </tr>
>       </table>
>       <table width='100%' border='0' cellspacing='0' cellpadding='2'
> class='boxbottom'>
>             <tr>
>               <td width="100%" align=center><div
> class="tabletext">TESTTESTTEST</div></td>
>             </tr>
>
>      </table>
> </table>
>
> <div id="enlargedImage" style="display:none">
>                 <!--table width="55%" border=0 cellpadding=0
> cellspacing=0 class="boxbottom" -->
>                 <table width="50%" border=0 cellpadding=0
cellspacing=0
> class="boxbottom">
>                         <tr>
>                          <td> <IMG name="largeImage" SRC="" ></td>
>                           <!-- <td ><IMG height="1754" width="1278"
> name="largeImage" src=""></td> -->
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                           <td> <input type="file" name="fileName"
> class="insideHeaderLink" alt="Import a file"> Add a file to this
> collection</td>
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                         <td><!-- <input type="submit"
> value="Upload/Finish"  alt="Save the new document information">
--></td>
>                   </tr>
>                 </table>
>
> </div>
>



-- 
G.Venkata Phanindra
Mob:: 9849852989

Re: image tag causing request to controller

Posted by "G.Venkata Phanindra" <ph...@gmail.com>.
Hi David and Others,
        Will it be going into a infinate loop? From my experience with other
MVC projects using struts i never had a problem, does our ofbiz Architecture
have a issue with this or is it in general ?

Regards
Phani

On 3/8/07, David Napolitan <dn...@alexanderinteractive.com> wrote:
>
> Hi,
>
> I was just looking into this same problem yesterday.  This is what I
> found:
>
> As you know, you will see this problem when you have an img tag with a
> blank or hashed value as the src attribute:
>
> <img src="#"/>  or <img src=""/>
>
> Since the src attribute doesn't start with a protocol, the browser will
> interpret this as a relative url.  It appends this value (" " or "#") to
> your current url when it goes to fetch this image.  As a result, it
> makes a request with a url matching that of your current page.  .. and
> you get these additional requests being made.
>
> I hope that helps.
>
> -Dave
>
>
>
> -----Original Message-----
> From: Tim McGuire [mailto:tmcguire@go-integral.com]
> Sent: Thursday, March 08, 2007 10:45 AM
> To: user@ofbiz.apache.org
> Subject: RE: image tag causing request to controller
>
> This behavior only happens when I give a blank src attribute  <img
> name="largeImage" src="">
> if I fill it in with garbage or delete it altogether, it works as
> expected.
>
>
> I've attached relevant portion of console.log
>
> the FTL file is pared down to a testing.ftl:
>
> <TABLE border=0 width='100%' cellspacing='0' cellpadding='0'
> class='boxoutside'>
>   <TR>
>     <TD width='100%'>
>       <table width='100%' border='0' cellspacing='0' cellpadding='0'
> class='boxtop'>
>         <tr>
>           <td width="100%"><div class="boxhead">TESTTESTTESTTESTTEST
> </div></td>
>
>         </tr>
>       </table>
>       <table width='100%' border='0' cellspacing='0' cellpadding='2'
> class='boxbottom'>
>             <tr>
>               <td width="100%" align=center><div
> class="tabletext">TESTTESTTEST</div></td>
>             </tr>
>
>      </table>
> </table>
>
> <div id="enlargedImage" style="display:none">
>                 <!--table width="55%" border=0 cellpadding=0
> cellspacing=0 class="boxbottom" -->
>                 <table width="50%" border=0 cellpadding=0 cellspacing=0
> class="boxbottom">
>                         <tr>
>                          <td> <IMG name="largeImage" SRC="" ></td>
>                           <!-- <td ><IMG height="1754" width="1278"
> name="largeImage" src=""></td> -->
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                           <td> <input type="file" name="fileName"
> class="insideHeaderLink" alt="Import a file"> Add a file to this
> collection</td>
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                         <td><!-- <input type="submit"
> value="Upload/Finish"  alt="Save the new document information"> --></td>
>                   </tr>
>                 </table>
>
> </div>
>



-- 
G.Venkata Phanindra
Mob:: 9849852989

RE: image tag causing request to controller

Posted by David Napolitan <dn...@alexanderinteractive.com>.
Hi,

I was just looking into this same problem yesterday.  This is what I
found:

As you know, you will see this problem when you have an img tag with a
blank or hashed value as the src attribute:

<img src="#"/>  or <img src=""/>

Since the src attribute doesn't start with a protocol, the browser will
interpret this as a relative url.  It appends this value (" " or "#") to
your current url when it goes to fetch this image.  As a result, it
makes a request with a url matching that of your current page.  .. and
you get these additional requests being made.

I hope that helps.

-Dave



-----Original Message-----
From: Tim McGuire [mailto:tmcguire@go-integral.com] 
Sent: Thursday, March 08, 2007 10:45 AM
To: user@ofbiz.apache.org
Subject: RE: image tag causing request to controller

This behavior only happens when I give a blank src attribute  <img
name="largeImage" src="">
if I fill it in with garbage or delete it altogether, it works as
expected.


I've attached relevant portion of console.log

the FTL file is pared down to a testing.ftl:

<TABLE border=0 width='100%' cellspacing='0' cellpadding='0'
class='boxoutside'>
  <TR>
    <TD width='100%'>
      <table width='100%' border='0' cellspacing='0' cellpadding='0'
class='boxtop'>
        <tr>
          <td width="100%"><div class="boxhead">TESTTESTTESTTESTTEST
</div></td>
          
        </tr>
      </table>
      <table width='100%' border='0' cellspacing='0' cellpadding='2'
class='boxbottom'>
            <tr>
              <td width="100%" align=center><div
class="tabletext">TESTTESTTEST</div></td>
            </tr>  

     </table>
</table>

<div id="enlargedImage" style="display:none">
		<!--table width="55%" border=0 cellpadding=0
cellspacing=0 class="boxbottom" -->
		<table width="50%" border=0 cellpadding=0 cellspacing=0
class="boxbottom">
			<tr>
			 <td> <IMG name="largeImage" SRC="" ></td>
			  <!-- <td ><IMG height="1754" width="1278"
name="largeImage" src=""></td> -->
			</tr>
			<tr><td>&nbsp</td></tr>
			<tr>
			  <td> <input type="file" name="fileName"
class="insideHeaderLink" alt="Import a file"> Add a file to this
collection</td>
			</tr>
			<tr><td>&nbsp</td></tr>
			<tr>
			<td><!-- <input type="submit"
value="Upload/Finish"  alt="Save the new document information"> --></td>
		  </tr>
		</table>
			
</div>

Re: image tag causing request to controller

Posted by "G.Venkata Phanindra" <ph...@gmail.com>.
Hi,
I saw the ftl code but could not find any problem as such ... but i could
not test it as i did not have enviroment set up now.. there is no
attachement to this. plese send the console which could give some
information.

Regards

G Venkata Phanindra

On 3/8/07, Tim McGuire <tm...@go-integral.com> wrote:
>
> This behavior only happens when I give a blank src attribute  <img
> name="largeImage" src="">
> if I fill it in with garbage or delete it altogether, it works as
> expected.
>
>
> I've attached relevant portion of console.log
>
> the FTL file is pared down to a testing.ftl:
>
> <TABLE border=0 width='100%' cellspacing='0' cellpadding='0'
> class='boxoutside'>
>   <TR>
>     <TD width='100%'>
>       <table width='100%' border='0' cellspacing='0' cellpadding='0'
> class='boxtop'>
>         <tr>
>           <td width="100%"><div class="boxhead">TESTTESTTESTTESTTEST
> </div></td>
>
>         </tr>
>       </table>
>       <table width='100%' border='0' cellspacing='0' cellpadding='2'
> class='boxbottom'>
>             <tr>
>               <td width="100%" align=center><div
> class="tabletext">TESTTESTTEST</div></td>
>             </tr>
>
>      </table>
> </table>
>
> <div id="enlargedImage" style="display:none">
>                 <!--table width="55%" border=0 cellpadding=0
> cellspacing=0 class="boxbottom" -->
>                 <table width="50%" border=0 cellpadding=0 cellspacing=0
> class="boxbottom">
>                         <tr>
>                          <td> <IMG name="largeImage" SRC="" ></td>
>                           <!-- <td ><IMG height="1754" width="1278"
> name="largeImage" src=""></td> -->
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                           <td> <input type="file" name="fileName"
> class="insideHeaderLink" alt="Import a file"> Add a file to this
> collection</td>
>                         </tr>
>                         <tr><td>&nbsp</td></tr>
>                         <tr>
>                         <td><!-- <input type="submit"
> value="Upload/Finish"  alt="Save the new document information"> --></td>
>                   </tr>
>                 </table>
>
> </div>
>



-- 
G.Venkata Phanindra
Mob:: 9849852989

RE: image tag causing request to controller

Posted by Tim McGuire <tm...@go-integral.com>.
This behavior only happens when I give a blank src attribute  <img
name="largeImage" src="">
if I fill it in with garbage or delete it altogether, it works as
expected.


I've attached relevant portion of console.log

the FTL file is pared down to a testing.ftl:

<TABLE border=0 width='100%' cellspacing='0' cellpadding='0'
class='boxoutside'>
  <TR>
    <TD width='100%'>
      <table width='100%' border='0' cellspacing='0' cellpadding='0'
class='boxtop'>
        <tr>
          <td width="100%"><div class="boxhead">TESTTESTTESTTESTTEST
</div></td>
          
        </tr>
      </table>
      <table width='100%' border='0' cellspacing='0' cellpadding='2'
class='boxbottom'>
            <tr>
              <td width="100%" align=center><div
class="tabletext">TESTTESTTEST</div></td>
            </tr>  

     </table>
</table>

<div id="enlargedImage" style="display:none">
		<!--table width="55%" border=0 cellpadding=0
cellspacing=0 class="boxbottom" -->
		<table width="50%" border=0 cellpadding=0 cellspacing=0
class="boxbottom">
			<tr>
			 <td> <IMG name="largeImage" SRC="" ></td>
			  <!-- <td ><IMG height="1754" width="1278"
name="largeImage" src=""></td> -->
			</tr>
			<tr><td>&nbsp</td></tr>
			<tr>
			  <td> <input type="file" name="fileName"
class="insideHeaderLink" alt="Import a file"> Add a file to this
collection</td>
			</tr>
			<tr><td>&nbsp</td></tr>
			<tr>
			<td><!-- <input type="submit"
value="Upload/Finish"  alt="Save the new document information"> --></td>
		  </tr>
		</table>
			
</div>

Re: image tag causing request to controller

Posted by "G.Venkata Phanindra" <ph...@gmail.com>.
Hi,
Can u please mail the complete ftl file and the stack trace in the console.

Regards,
G Venkata Phanindra
On 3/8/07, Tim McGuire <tm...@go-integral.com> wrote:
>
> Hello list,
>
> I have a confusing error in which an image tag on an FTL page is
> triggering a request that is being routed through the controller and
> causing all of the associated events for that request to be executed
> twice (or three times if there are two image tags).  I've been staring
> at my controller.xml and my web.xml to discover why this is happening
> and I can't see it.
>
> 1) where can I set a debugging breakpoint to view the contents of the
> request object before it hits the controller.
> 2) why is this happening in the first place?
>
> here is the offending line in FTL page:
> <IMG name="largeImage" src="" >
>
> here is part of web.xml:
>
> <filter>
>         <filter-name>ContextFilter</filter-name>
>         <display-name>ContextFilter</display-name>
>
> <filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
>         <init-param>
>             <param-name>disableContextSecurity</param-name>
>             <param-value>N</param-value>
>         </init-param>
>         <init-param>
>             <param-name>allowedPaths</param-name>
>             <param-value>
>
> /control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/imag
> es:/scanjobs:/includes/maincss.css:/ImageServer</param-value>
>         </init-param>
>         <init-param>
>             <param-name>errorCode</param-name>
>             <param-value>403</param-value>
>         </init-param>
>         <init-param>
>             <param-name>redirectPath</param-name>
>             <param-value>/control/main</param-value>
>         </init-param>
>     </filter>
>     <filter-mapping>
>         <filter-name>ContextFilter</filter-name>
>             <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
> here is part of controller (the mapping that is getting executed - it is
> the populateMetadata method that gets executed more than once):
> <request-map uri="updateMetadata">
>         <security https="false" auth="true"/>
>         <event type="java"
>
> path="com.gointegral.opendm.scanstation.events.ScanstationEvents"
>             invoke="populateMetadata"/>
>         <response name="assetUploadSuccess" type="view"
> value="updateMetadataSuccess"/>
>         <response name="scanSuccess" type="view"
> value="updateMetadataSuccess"/>
>         <response name="error" type="view" value="error"/>
>     </request-map>
>
> Tim McGuire
> Integral Business Solutions
>



-- 
G.Venkata Phanindra
Mob:: 9849852989