Thanks for your answer.

If i set validate="true" the layout is not applied. I see only the page
"createuser.jsp"

If i set validate="false" it works fine...

Why?


Ok here my config files:
If you nee more informations, just say it.

struts-config.xml

<action input="/createuser.jsp"
name="CreateUserActionForm" path="/createuser" scope="request"
type="com.myapp.struts.CreateUser" validate="false" >
<forward name="success" path="page.welcome"/>
<forward name="failed" path="page.createuser"/>
</action>

#################################################################
tiles-defs.xml

    <!-- Tiles Definition of Create User -->
    <definition name="page.createuser" extends="base.definition">
        <put name="title" value="User erstellen" />
        <put name="body" value="/createuser.jsp" />
    </definition>

##################################################################
createuser.jsp:

<html:form action="createuser">
    <table border="1">

        <tr>
            <td><bean:message key="user.nick" /></td>
            <td><html:text property="nick"  /></td>

        </tr>
        <tr>
            <td><bean:message key="user.name" /></td>
            <td><html:text property="name"  /></td>
        </tr>
        <tr>
[..More inputs..]


    </table>



    <html:submit />  <html:reset />
    <span style="color: red">
        <html:errors/>
    </span>
</html:form>

#########################################
createUserActionForm.java

public class CreateUserActionForm extends
org.apache.struts.action.ActionForm {

    private int id;
    private String nick;
    private String name;
        [..]

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }
[...]

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
        ActionErrors errors = new ActionErrors();

if (getNick() == null || getNick().length() < 4 ) {
            errors.add("nick", new ActionMessage("error.nick.required"));
        }

if (getName() == null || getName().length() < 4) {
            errors.add("name", new ActionMessage("error.name.required"));
}
if (getVname() == null || getVname().length() < 4) {
            errors.add("name", new ActionMessage("error.vname.required"));
}
[...]
 return errors;

##########################################
CreateUser.java

public class CreateUser extends Action {

    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    private final static String FAILED = "failed";

 public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
 CreateUserActionForm createuser = (CreateUserActionForm) form;

            user newuser = new user();
          newuser.setNick(createuser.getNick());
            newuser.setName(createuser.getName());
            newuser.setVname(createuser.getVname());
[...]
 if (!userliste.reg_user(newuser)){
return mapping.findForward(FAILED);
            }

return mapping.findForward(SUCCESS);


##########################################


Laurie Harper schrieb:
> You can certainly use automatic validation together with Tiles, so
> that's not the problem. You'll need to post your relevant
> struts-config.xml excerpts and tiles-defs, and possibly relevant bits of
> JSP so we can see what you're doing wrong.
> 
> L.
> 
> Sebastian Marten wrote:
>> After several hours of searching i found the problem.
>> All pages work, if I set >validate="false"< in the struts config.
>> So I can't use the validate method of the bean?
>> Is there an alternative for this method?
>>
>> Best regards,
>> Sebastian Marten
>>
>>
>> Sebastian Marten schrieb:
>>> Hello List,
>>>
>>> I have a problem with Struts Tiles.
>>>
>>> First I wrote all sub-page's for a very little Web shop.
>>>
>>> Then i started with tiles and created a simple test layout.
>>> Nothing special, but it works.
>>> I have several normal pages, like the page "katliste.jsp"
>>> I click the link to the related action:
>>>
>>> <html:link action="katliste">Unser Angebot</html:link>
>>> And then the page is displayed in the Layout.
>>>
>>> So far, so good.
>>> Then I have 2 pages with a Struts Action Form and Action Form bean.
>>> I Created the definition for this page in the tiles-xml and configured
>>> the action forwards in the struts-config.
>>> But then i create a link the /createuser.do:
>>> <html:link action="createuser">Hier können sie sich Anmelden</html:link>
>>>
>>> I see only the corresponding .jsp page an not the hole layout.
>>>
>>> There is the Problem?
>>>
>>> I hope you can help me!
>>>
>>> Best regards,
>>> Sebastian Marten
>>>
>> [.....]
>>
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to