[s2] Radio buttons example

2007-06-22 Thread Matt.Luce

Did you find any documentation on radio buttons?




RE: Programmatic Validation in Action

2007-06-09 Thread Matt.Luce
Sure, it's really simple:

 action name=save class=exampleAction // this is action is
configured in spring
result name=input/update.jsp/result
result/update.jsp/result
result name=error/update.jsp/result
/action

When it goes to the input result, the values I typed in are no longer
present.

-Original Message-
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 09, 2007 2:49 PM
To: Struts Users Mailing List
Subject: Re: Programmatic Validation in Action

--- Matt Luce [EMAIL PROTECTED] wrote:
 Has anyone attempted to use programmatic validation in Struts 2?

Sure, although I still used the validation interfaces.

What does your mapping look like?

d.



   


Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



ModelDriven interface

2007-06-09 Thread Matt.Luce
I'm working with Struts 2.0.6 and I'm trying to use the ModelDriven
Interface.  However, I seem to be having some troubles.  My actionClass
implements ModelDriven, but the values on the page don't fill with the
values of the object returned by getModel().  If I explicitly declare
the getXxx() methods for each attribute of the model within the
Action, the values are populated in the .jsp form.  

Matt Luce 
Wells Fargo Funds Management, LLC 
414.577.7927 
414.359.3537 Fax 



Re: ModelDriven interface

2007-06-09 Thread Matt.Luce
Then why have the modelDriven interface at all?  What use is it?  

Matt Luce 
Wells Fargo Funds Management, LLC 
414.577.7927 
414.359.3537 Fax 



Re: ModelDriven interface

2007-06-09 Thread Matt.Luce
I agree, it should be on the stack, but the values don't show up.  Does
anyone have an example of this that works?





Re: ModelDriven interface

2007-06-09 Thread Matt.Luce
I'm using the default stack.  What I'm trying to do is something very
simple, that was incredibly straightforward in Struts 1.  What I'm
finding is the getModel() method is not getting called when I expect it
to.  It doesn't get called until after the action has been hit once.
But that doesn't help, because the input page doesn't hit the action
until the form is submitted.  So somehow, I need to get my bean (the
object returned by getModel()) on the ValueStack before the input page
is rendered.  I have no idea how to do that.  In Struts 1, all I had to
do was create the form bean in a pre-action, throw it in session, then
forward to the input page.  I don't know why Struts 2 doesn't allow for
something that simple.





RE: ModelDriven interface

2007-06-09 Thread Matt.Luce
Here is the flow of my tiny app: 

listAction - list.jsp - selectAction - update.jsp - updateAction
(implements ModelDriven - getModel() returns the object selected in
list.jsp stored in session )

Once it gets to update.jsp, the form should show the values of the bean
selected on list.jsp.  But, since getModel() is not called until the
update.jsp is posts to updateAction, the model is not on the value
stack.
-
struts.xml:

struts
include file=struts-default.xml/
constant name=struts.devMode value=true/
constant name=struts.ui.theme value=simple/

constant name=struts.objectFactory
value=org.apache.struts2.spring.StrutsSpringObjectFactory /


package name=default extends=struts-default

action name=list class=listAction
result/list.jsp/result
result name=error/index.jsp /result
/action

action name=select class=selectAction
result/update.jsp/result
/action

action name=save class=updateAction
result name=input/update.jsp/result
result/update.jsp/result
result name=error/update.jsp/result
/action

/package

/struts 

---
ListAction:
import com.wellsfargo.fmg.appaudit.domain.AuditCode;

import java.util.ArrayList;
import java.util.List;

public class ListAction extends AppAuditAction {
public String execute()
{
List codes = new ArrayList();
AuditCode code = new AuditCode();
code.setCode(1);
code.setDescription(Really cool code);
codes.add(code);
this.getSession().put(codes,codes);
return SUCCESS;
}

}
-

list.jsp
%@ taglib prefix=s uri=/struts-tags % %@ taglib
uri=/WEB-INF/c.tld prefix=c % html head
titleApp Audit Maint/title
/head
body
h2
   App Audit Code Listing
/h2
table
s:iterator value=#attr.codes
tr
td
s:property value=code / - s:property
value=description /
s:url id=selectUrl value=/select.action 
  s:param name=code value=code /
/s:url
s:a href=%{selectUrl}Edit/s:a
/td
/tr
/s:iterator
/table
/body
/html
-
SelectAction:
import com.wellsfargo.fmg.appaudit.domain.AuditCode;

import java.util.Iterator;
import java.util.List;

public class SelectAction extends AppAuditAction {
public String execute() throws Exception
{
String[] codeParam = (String[])this.getParameters().get(code);
List codes = (List)this.getSession().get(codes);

for (Iterator it = codes.iterator();it.hasNext();)
{
AuditCode c = (AuditCode)it.next();
if (c.getCode() == Integer.valueOf(codeParam[0]).intValue())
{
this.getSession().put(auditCode,c);
break;
}
}
return SUCCESS;
}
}
-
update.jsp

%@ taglib prefix=s uri=/struts-tags % html head
titleApp Audit Maint/title
/head
body
h2
   Update Audit Code
/h2
s:actionerror/
s:form action=save
table
tr
td
Code: s:property value=code/
/td
/tr
tr
td
Description: s:textfield name=description/
/td
/tr
/table
s:submit value=submit/
/s:form
/body
/html

-
import com.opensymphony.xwork2.ModelDriven;
import com.wellsfargo.fmg.appaudit.domain.AuditCode;

public class UpdateAction extends AppAuditAction implements ModelDriven
{
public UpdateAction()
{
System.out.println(UPDATE action constructor);
}

public String execute() throws Exception
{
this.addActionError(Error On Execute);
return INPUT;
}

public int getCode()
{
AuditCode auditCode =
(AuditCode)this.getSession().get(auditCode);
return auditCode.getCode();
}

public String input() throws Exception
{
return super.input();//To change body of overridden methods
use File | Settings | File Templates.
}

public Object getModel()
{
System.out.println(getModel Called);
AuditCode auditCode =
(AuditCode)this.getSession().get(auditCode);
return auditCode;
//return this.auditCode;
}
}

the super class for all my actions:

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.ParameterAware;

import java.util.Map;

public abstract class AppAuditAction extends ActionSupport implements
SessionAware, RequestAware, ParameterAware {
private Map session;
private Map request;
private Map parameters;

public void setSession(Map map)
{
this.session = map;
}

public void setRequest(Map map)
{
this.request = map;
}

public void 

Struts 2 nocache

2007-06-09 Thread Matt.Luce
What is the best way to implement the struts 1 nocache functionality
(controller  nocache=true/) in struts 2?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]