[ https://issues.apache.org/struts/browse/WW-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46990#action_46990 ]
Andreas Krüger commented on WW-3306: ------------------------------------ For details: I'm using this Action class: public class StrutsBugAction implements ModelDriven<StrutsBugModel>, Action { private final StrutsBugModel model = new StrutsBugModel(); private boolean bomb = false; public StrutsBugAction() {} public StrutsBugModel getModel() { return model; } public String getActionprop() { return null; } public void setActionprop(String actionProp) { } public String execute() { return SUCCESS; } public boolean getBomb() { return bomb; } public void setBomb(boolean bomb) { this.bomb = bomb; } } I'm using this Model class: public class StrutsBugModel { public String getModelprop() {return null;} public void setModelprop(String foo) {} } I'm using this JSP as a view: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Weird struts behaviour</title> </head> <body> <h1>Weird struts behaviour</h1> <p style="font-size:120%">See <a href="https://issues.apache.org/struts/browse/WW-3306">https://issues.apache.org/struts/browse/WW-3306</a> .</p> <h2>All of these work</h2> <s:if test="modelprop == null"> <p>Property <code>modelprop</code> from the model is null, as <code><s:if></code> is happy to tell us.</p> </s:if> <s:else> <p>Property <code>modelprop</code> from the model is not null. (Well, it is, so this text never shows.)</p> </s:else> <s:if test="actionprop == null"> <p>Property <code>actionprop</code> from the action is null, as <code><s:if></code> is happy to tell us.</p> </s:if> <s:else> <p>Property <code>actionprop</code> from the action is not null. (Well, it is, so this text never shows.)</p> </s:else> <p>Applying a null into the text, from an action property, here it comes: “<s:property value="actionprop" />” - this works and causes no problems, even though we have set <code>struts.el.throwExceptionOnFailure=true</code> in <code>struts.properties</code> .</p> <h2>This does not work</h2> <p>Applying a null into the text, from a <em>model</em> property, using exactly the same code as above, does not work whenever we have set <code>struts.el.throwExceptionOnFailure=true</code> in <code>struts.properties</code>. The only difference is that this is a property from a model, not one from an action.</p> <s:if test="bomb"> <p>“<s:property value="modelprop" />”</p> </s:if> <s:else> <p><s:a ><s:param name="bomb" value="true"/>Click here</s:a> to expose the bug.</p> </s:else> </body> </html> > Null value accepted from action property, but not model property when > throwExceptionOnFailure=true > -------------------------------------------------------------------------------------------------- > > Key: WW-3306 > URL: https://issues.apache.org/struts/browse/WW-3306 > Project: Struts 2 > Issue Type: Bug > Components: Value Stack > Affects Versions: 2.1.8 > Reporter: Andreas Krüger > > In this project, we experiment with setting > struts.el.throwExceptionOnFailure=true to catch errors. > We use <s:property value="myprop" /> in our JSP. > Occasionally, the property thus referenced is null. We want struts to insert > an empty string in that case. > This it duely does, when either struts.el.throwExceptionOnFailure=false or > when the property is from an action object. > However, if the property is from a model object and > struts.el.throwExceptionOnFailure=true, this bombs out. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.