Hi Aner,

This is an annoying "feature" of the Workflow interceptor.  If
ValidationAware.hasErrors() returns true, the interceptor chain is
stopped and Action.INPUT is returned. If you put error messages on your
action, it will make hasErrors return true which will force the "input"
result to be returned.

Your options are:

1. Add an "input" result to your config as previously stated

Do not know where/what should be set in struts.xml :-(

2. use addActionMessage() instead
This solution I tried, and it works fine!


3. Override this behavior (override hasErrors() or muck with the
interceptor config)

this is takes more time; I may not pick this one.


If I could not make (1) works, I will probably pick (2).

Till now, I am already very satisfied with the answer! Thanks you very much!

Emi


On 04/14/2011 10:12 AM, Emi Lu wrote:

I'm still guessing it's a validation thing--put an "input" result in
there and check.

Also, by naming the results the same as the actions you're actually
circumventing one of the reasons for abstracting the result names from
everything else. Even for test apps it's just not a good habit, IMO.

So, what is the reason? I did not put input :-(

I am looking for the answer......

Emi



On Wed, Apr 13, 2011 at 4:43 PM, Emi Lu<em...@encs.concordia.ca> wrote:
Depends on where you added the addActionError() call, at the very
least--an action error indicates a validation problem, so it may be
trying to go to the "input" result.

Not enough information to help.

It seems that I may get my answer soon!

More info comes:
=========================
(1) Action1.java
public class Action1 extends ActionSupport
{ .. ....
public String execute() throws Exception
{
HttpServletRequest req = ServletActionContext.getRequest();
HttpServletResponse res = ServletActionContext.getResponse();
/* paging method for display tag */
process_paging(req);
return SUCCESS;
} ...
}


(2) Action1 in struts.xml
<action name="*Action1" method="{1}" class="Action1">
<result name="success" type="tiles">browse_action1</result>
</action>


(3) tiles for browse_action1
<definition name= "browse_action1" template="t.jsp">
<put-attribute name="body" value="browse_action1.jsp" />
</definition>


(4) browse_action1.jsp
... ...
<s:form id="Action1Form"
name="Action1Form"
action="Action1"
validate="true"
theme="simple">
<display:table id="row_rec"
name="alist_paging_bean"
export="true"
class="simple"
cellspacing="0"
cellpadding="5"
requestURI="Action1"
keepStatus="true"
pagesize="<%=bean_display.getPageSize() %>"
partialList="true"
size="<%=bean_display.getTotalRecNum() %>"
sort="external"

<display:column property="c1" title="c1" sortName="c1"
sortable="true"/>
... ...
</display:table>

<s:submit value="Update" theme="simple" action="update_guiAction2">
</s:submit>
</s:form>


(5) Action2.java
public class ProcessThesis extends ActionSupport
{
public String update_gui() throws Exception
{
HttpServletRequest req = ServletActionContext.getRequest();
HttpServletResponse res = ServletActionContext.getResponse();
String[] error_arr = new String[2];
String[] checkbox_value =req.getParameterValues("checkbox_value");
if(Utils.isEmpty(checkbox_value))
{
addActionError(this.getText("at.least.one.rec.error"));
return "view_action1"; //Step_Q1 -> "Page not found()404"
}

return "view_action1" ; //Step_Q2 -> no error at all
}
}


If remove "addActionError(this.getText("at.least.one.rec.error"))",
return
successfully! Otherwise, "Page not found 404"returned!

(6) struts.xml for Action2
<action name="*Action2" method="{1}" class="Action2">
<result name="view_action1" type="redirectAction">
<param name="actionName">Action1</param>
</result>
</action>

I tried also the following, but it does not work either:
<action name="*Action2" method="{1}" class="Action2">
<result name="view_action1" type="tiles">browse_action1</result>
</action>

Thanks a lot!
Emi






On Wed, Apr 13, 2011 at 3:19 PM, Emi Lu<em...@encs.concordia.ca>
wrote:

Hello,

addActionError() caused "Page not found (404)" Error.

(1) Action1.java
browsing all records using displaytag

(2) Action2.java
if just say:
return "view"; go to Action1 successfully

if:
addActionError(...); //then
return "view";
Got an "Page not found (404)" exception.

Does anyone know what cause the problem?

Thanks a lot!
Emi

--
<result name="view" type="redirectAction">
<param name="actionName">ProcessAction1</param>
<param name="namespace">/Action</param>
</result>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


--
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
em...@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to