You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ahmed Hashim <en...@gmail.com> on 2006/04/09 17:50:52 UTC

problem in tiles

what is wrong with this configuration?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd
">

<struts-config>
  <data-sources />

  <form-beans>
      <form-bean name="loginForm" type="evote.form.LoginActionForm">
      </form-bean>
  </form-beans>

  <global-exceptions />
  <global-forwards />

  <action-mappings>


  </action-mappings>
  <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"
/>

  <message-resources parameter="evote.struts.language.ApplicationResources"
/>
   <plug-in className="org.apache.struts.tiles.TilesPlugin">
    <set-property property="definitions-config" value="/WEB-INF/tiles-
def.xml"/>
     <set-property property="definitions-debug" value="2" />
  <set-property property="definitions-parser-details" value="2" />
  <set-property property="definitions-parser-validate" value="true" />
  <set-property property="moduleAware" value="true" />
  </plug-in>

</struts-config>


<?xml version='1.0'?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles
Configuration 1.1//EN" "
http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name="genericLayout" path="/jsp/layout/layout.jsp">
    <put name="title" value="Electronic Voting System" />
    <put name="menu" value="/jsp/layout/menu.jsp" />
    <put name="header" value="/jsp/layout/header.jsp" />
    <put name="footer" value="/jsp/layout/footer.jsp" />
    <put name="body" value="/jsp/layout/body.jsp" />
</definition>

<definition name="loginPage.page" extends="genericLayout">
    <put name="body" value="/jsp/login.jsp" />
</definition>
</tiles-definitions>

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

</web-app>

when i try to request http://localhost:8080/Evote/loginPage.do i got the
message SEVERE: Invalid path /loginPage was requested

what do you think the problem?

--
In Life, it doesn't matter who you are, but whether someone appreciates you
for what you are, accepts you and loves you unconditionally. A Real Friend (
Friendship ) is one who walks in when the rest of the world walks away.

Re: problem in tiles

Posted by Antonio Petrelli <br...@tariffenet.it>.
Ahmed Hashim ha scritto:
> ...
> but i remember that I can request the page directly...
>   

You remember wrong! You cannot request a Tiles definition directly. You 
have at least to write a simple JSP page with <tiles:insert> tag.
You can invoke a Tiles definition directly only through a forward, if 
you are using TilesRequestProcessor
Ciao
Antonio


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


Re: problem in tiles

Posted by Ahmed Hashim <en...@gmail.com>.
Thanks Antonio,

Actually in my application I didn't allow the user to expose any jsp using
the action. I used this techniques for a certain type of pages using a
specific pattern in the generic action.

So, I think it is more secure.

Thanks.

Ahmed Hashim

On 4/14/06, Antonio Petrelli <br...@tariffenet.it> wrote:
>
> Ahmed Hashim ha scritto:
> > I solved the problem
> >
> > I think you are right, I can not call any tiles definition directly
> without
> > calling an action
> >
> > I made a generic action definition to view my pages
> >
> > check the solution in my blog
> >
> > http://www.egjug.org/struts_action_foward_to_Tiles
> >
> >
> > Ahmed Hashim
> >
>
> Uh at a first look, I did not like your solution, because I thought that
> it could break security, that it is just like exposing JSP pages without
> passing through an action. But then I thought "hey wait a moment, if I
> want to expose a definition, I NEED to call it 'viewSomething.page' and
> not 'blahblah'", so security is preserved if the programmer knows what
> to do.
> Congratulations, I really liked your solution!
> Ciao
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
In Life, it doesn't matter who you are, but whether someone appreciates you
for what you are, accepts you and loves you unconditionally. A Real Friend (
Friendship ) is one who walks in when the rest of the world walks away.

Re: problem in tiles

Posted by Antonio Petrelli <br...@tariffenet.it>.
Ahmed Hashim ha scritto:
> I solved the problem
>
> I think you are right, I can not call any tiles definition directly without
> calling an action
>
> I made a generic action definition to view my pages
>
> check the solution in my blog
>
> http://www.egjug.org/struts_action_foward_to_Tiles
>
>
> Ahmed Hashim
>   

Uh at a first look, I did not like your solution, because I thought that 
it could break security, that it is just like exposing JSP pages without 
passing through an action. But then I thought "hey wait a moment, if I 
want to expose a definition, I NEED to call it 'viewSomething.page' and 
not 'blahblah'", so security is preserved if the programmer knows what 
to do.
Congratulations, I really liked your solution!
Ciao
Antonio

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


Re: problem in tiles

Posted by Ahmed Hashim <en...@gmail.com>.
I solved the problem

I think you are right, I can not call any tiles definition directly without
calling an action

I made a generic action definition to view my pages

check the solution in my blog

http://www.egjug.org/struts_action_foward_to_Tiles


Ahmed Hashim

On 4/10/06, Dave Newton <ne...@pingsite.com> wrote:
>
> Ahmed Hashim wrote:
> > I tried to forward to loginPage.page from the action and it is working
> fine,
> > but i remember that I can request the page directly...
> > any suggestion?
> >
>
> You can use tile definitions as "input" or "forward" attribute values in
> your Struts config file; is that what you mean?
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
In Life, it doesn't matter who you are, but whether someone appreciates you
for what you are, accepts you and loves you unconditionally. A Real Friend (
Friendship ) is one who walks in when the rest of the world walks away.

ActionForm and JavaBean Specifications

Posted by Carl Smith <cc...@yahoo.com>.
  JavaBeans Specification doesn't allow more than one setter method (with different argument signatures) for the same property, in other words, JavaBeans specification doesn't allow the method overloading for property setters, does this also apply for Struts ActionForms? Is so, why I did have an over loaded getter methods in an ActionForm and it works fine?
   
  Thanks.
   

		
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.

indexed property validation error:java.lang.reflect.InvocationTargetException

Posted by Carl Smith <cc...@yahoo.com>.
I have a jsp containing three text fields which are indexed property, I needs to validate all the text box contains a value other than null or empth string. When I click on save I got the error (see the bottom). Your helps are highly appreciated!
   
  jsp:
  <html:errors/>
<html:form action="/testingSaveAction" method="post">
 
 (1) indexed property - text box
 <br />
 <logic:iterate name="testingForm" property="listOfItems" id="labelValue">
 Fields to be validated: <html:text name="labelValue" property="value" indexed="true"/><br />
 </logic:iterate> 
 <br /><br />
   <html:submit property="submit">save</html:submit>
  </html:form>  
   
  ActionForm:
public class TestingForm extends ValidatorActionForm {
     
 private LabelValueBean[] listOfItems;
 private LabelValueBean labelValue=null;
 
 
 public LabelValueBean getLabelValue(int index) {
  return (LabelValueBean)listOfItems[index];
 }
 
 public void setLabelValue(LabelValueBean bean, int index) {
  listOfItems[index]= bean;
 }
   public LabelValueBean[] getListOfItems() {
  return listOfItems;
 }
   public void setListOfItems(LabelValueBean[] beans) {
  listOfItems = beans;
 }   
}
   
  Actions:
public class DisplayAction extends org.apache.struts.action.Action { 
    
 public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws NestedException {
    
  TestingForm testingForm = (TestingForm) form;
  
  if (null == testingForm || null ==testingForm.getListOfItems()) {
   LabelValueBean[] listOfItems = new   LabelValueBean[3];
   LabelValueBean bean1 = new LabelValueBean("1", "");
   LabelValueBean bean2 = new LabelValueBean("2", "");
   LabelValueBean bean3 = new LabelValueBean("3", "");
   listOfItems[0]=bean1;
   listOfItems[1]=bean2;
   listOfItems[2]=bean3;
   testingForm.setListOfItems(listOfItems); 
  }
  
         return mapping.findForward("success");
 }
}
  
public class TestingSaveAction extends org.apache.struts.action.Action{
   
 public ActionForward executeAction(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response)
  throws NestedException {
  
  TestingForm testingForm = (TestingForm) form;
  
  return mapping.findForward("success");
 }
   
  struts-config.xml
<global-forwards>
       <forward name="displayTesting" path="/displayAction.do"/>
</global-forwards>
  <form-bean name="testingForm" type="MyPath.TestingForm" />
  <action path="/displayAction" type="MyPath.DisplayAction" 
  name="testingForm" scope="request" 
  validate="false" >
  <forward name="success" path="/MyPath/testing.jsp" /> 
</action>
  
<action path="/testingSaveAction" type="MyPath.TestingSaveAction" 
  name="testingForm" scope="request" 
  validate="true" input="displayTesting">
  <forward name="success" path="/MyPath/successful.jsp" />  
</action> 
 
  validation.xml
 <form name="/testingSaveAction"> 
          <field property="value" indexedListProperty="listOfItems" depends="required">
             <msg name="required" key="Keytoerrormessage.cannotblank"/>
   </field>
          
  </form>
  
 
  Errors when click on save:
E SRVE0026E: [Servlet Error]-[BeanUtils.populate]: java.lang.reflect.InvocationTargetException: java.lang.NullPointerException
 at MyPath.TestingForm.getLabelValue(TestingForm.java:75)
 at java.lang.reflect.Method.invoke(Native Method)
 at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:493)
  where line 75 is the place: return (LabelValueBean)listOfItems[index]; in the actionform
  

 

		
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1&cent;/min.

Re: problem in tiles

Posted by Dave Newton <ne...@pingsite.com>.
Ahmed Hashim wrote:
> I tried to forward to loginPage.page from the action and it is working fine,
> but i remember that I can request the page directly...
> any suggestion?
>   

You can use tile definitions as "input" or "forward" attribute values in
your Struts config file; is that what you mean?

Dave



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


Re: problem in tiles

Posted by Ahmed Hashim <en...@gmail.com>.
I tried to forward to loginPage.page from the action and it is working fine,
but i remember that I can request the page directly...
any suggestion?

On 4/9/06, Yang Sun <ae...@gmail.com> wrote:
>
> I think you should add an action in the action-mappings section for
> loginPage action. You request have not been processed by tiles yet.
>
> // Yang
>
> On 4/9/06, Ahmed Hashim <en...@gmail.com> wrote:
> >
> > what is wrong with this configuration?
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
> Struts
> > Configuration 1.2//EN" "
> > http://struts.apache.org/dtds/struts-config_1_2.dtd
> > ">
> >
> > <struts-config>
> >   <data-sources />
> >
> >   <form-beans>
> >       <form-bean name="loginForm" type="evote.form.LoginActionForm">
> >       </form-bean>
> >   </form-beans>
> >
> >   <global-exceptions />
> >   <global-forwards />
> >
> >   <action-mappings>
> >
> >
> >   </action-mappings>
> >   <controller processorClass="
> > org.apache.struts.tiles.TilesRequestProcessor"
> > />
> >
> >   <message-resources parameter="
> evote.struts.language.ApplicationResources
> > "
> > />
> >    <plug-in className="org.apache.struts.tiles.TilesPlugin">
> >     <set-property property="definitions-config" value="/WEB-INF/tiles-
> > def.xml"/>
> >      <set-property property="definitions-debug" value="2" />
> >   <set-property property="definitions-parser-details" value="2" />
> >   <set-property property="definitions-parser-validate" value="true" />
> >   <set-property property="moduleAware" value="true" />
> >   </plug-in>
> >
> > </struts-config>
> >
> >
> > <?xml version='1.0'?>
> > <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD
> > Tiles
> > Configuration 1.1//EN" "
> > http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
> > <tiles-definitions>
> > <definition name="genericLayout" path="/jsp/layout/layout.jsp">
> >     <put name="title" value="Electronic Voting System" />
> >     <put name="menu" value="/jsp/layout/menu.jsp" />
> >     <put name="header" value="/jsp/layout/header.jsp" />
> >     <put name="footer" value="/jsp/layout/footer.jsp" />
> >     <put name="body" value="/jsp/layout/body.jsp" />
> > </definition>
> >
> > <definition name="loginPage.page" extends="genericLayout">
> >     <put name="body" value="/jsp/login.jsp" />
> > </definition>
> > </tiles-definitions>
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance" version="2.4"
> > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> >   <servlet>
> >     <servlet-name>action</servlet-name>
> >     <servlet-class>org.apache.struts.action.ActionServlet
> </servlet-class>
> >     <init-param>
> >       <param-name>config</param-name>
> >       <param-value>/WEB-INF/struts-config.xml</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>debug</param-name>
> >       <param-value>3</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>detail</param-name>
> >       <param-value>3</param-value>
> >     </init-param>
> >     <load-on-startup>2</load-on-startup>
> >   </servlet>
> >   <servlet-mapping>
> >     <servlet-name>action</servlet-name>
> >     <url-pattern>*.do</url-pattern>
> >   </servlet-mapping>
> >
> > </web-app>
> >
> > when i try to request http://localhost:8080/Evote/loginPage.do i got the
> > message SEVERE: Invalid path /loginPage was requested
> >
> > what do you think the problem?
> >
> > --
> > In Life, it doesn't matter who you are, but whether someone appreciates
> > you
> > for what you are, accepts you and loves you unconditionally. A Real
> Friend
> > (
> > Friendship ) is one who walks in when the rest of the world walks away.
> >
>
>


--
In Life, it doesn't matter who you are, but whether someone appreciates you
for what you are, accepts you and loves you unconditionally. A Real Friend (
Friendship ) is one who walks in when the rest of the world walks away.

Re: problem in tiles

Posted by Yang Sun <ae...@gmail.com>.
I think you should add an action in the action-mappings section for
loginPage action. You request have not been processed by tiles yet.

// Yang

On 4/9/06, Ahmed Hashim <en...@gmail.com> wrote:
>
> what is wrong with this configuration?
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
> Configuration 1.2//EN" "
> http://struts.apache.org/dtds/struts-config_1_2.dtd
> ">
>
> <struts-config>
>   <data-sources />
>
>   <form-beans>
>       <form-bean name="loginForm" type="evote.form.LoginActionForm">
>       </form-bean>
>   </form-beans>
>
>   <global-exceptions />
>   <global-forwards />
>
>   <action-mappings>
>
>
>   </action-mappings>
>   <controller processorClass="
> org.apache.struts.tiles.TilesRequestProcessor"
> />
>
>   <message-resources parameter="evote.struts.language.ApplicationResources
> "
> />
>    <plug-in className="org.apache.struts.tiles.TilesPlugin">
>     <set-property property="definitions-config" value="/WEB-INF/tiles-
> def.xml"/>
>      <set-property property="definitions-debug" value="2" />
>   <set-property property="definitions-parser-details" value="2" />
>   <set-property property="definitions-parser-validate" value="true" />
>   <set-property property="moduleAware" value="true" />
>   </plug-in>
>
> </struts-config>
>
>
> <?xml version='1.0'?>
> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD
> Tiles
> Configuration 1.1//EN" "
> http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
> <tiles-definitions>
> <definition name="genericLayout" path="/jsp/layout/layout.jsp">
>     <put name="title" value="Electronic Voting System" />
>     <put name="menu" value="/jsp/layout/menu.jsp" />
>     <put name="header" value="/jsp/layout/header.jsp" />
>     <put name="footer" value="/jsp/layout/footer.jsp" />
>     <put name="body" value="/jsp/layout/body.jsp" />
> </definition>
>
> <definition name="loginPage.page" extends="genericLayout">
>     <put name="body" value="/jsp/login.jsp" />
> </definition>
> </tiles-definitions>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" version="2.4"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>   <servlet>
>     <servlet-name>action</servlet-name>
>     <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>     <init-param>
>       <param-name>config</param-name>
>       <param-value>/WEB-INF/struts-config.xml</param-value>
>     </init-param>
>     <init-param>
>       <param-name>debug</param-name>
>       <param-value>3</param-value>
>     </init-param>
>     <init-param>
>       <param-name>detail</param-name>
>       <param-value>3</param-value>
>     </init-param>
>     <load-on-startup>2</load-on-startup>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>action</servlet-name>
>     <url-pattern>*.do</url-pattern>
>   </servlet-mapping>
>
> </web-app>
>
> when i try to request http://localhost:8080/Evote/loginPage.do i got the
> message SEVERE: Invalid path /loginPage was requested
>
> what do you think the problem?
>
> --
> In Life, it doesn't matter who you are, but whether someone appreciates
> you
> for what you are, accepts you and loves you unconditionally. A Real Friend
> (
> Friendship ) is one who walks in when the rest of the world walks away.
>