Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 12 Jul 2009 13:41:54 -0000 Issue 8745

user-digest-help

2009-07-12


Author LoginPost Reply

user Digest 12 Jul 2009 13:41:54 -0000 Issue 8745

Topics (messages 200599 through 200620):

Struts 2.1.6's bug? or my configuration error?
 200599 by: Yuan12345

Re: Help with JSP and javascript
 200600 by: dusty

XML Validation
 200601 by: Muhammad Owais
 200613 by: Dave Newton

Re: assigning a JSP variable a value coming from <s: property>
 200602 by: Farshad Rabbani

"Nothing found to display" from display tag with struts 2
 200603 by: Dimitrios Christodoulakis
 200604 by: dusty
 200605 by: Dimitrios Christodoulakis
 200607 by: Wes Wannemacher

updating or deleting a component from a collection through display tag
 200606 by: Dimitrios Christodoulakis

JSP Recursion and the Struts include Tag
 200608 by: Anthony Frasso
 200609 by: Avlesh Singh
 200610 by: Anthony Frasso
 200611 by: Avlesh Singh
 200612 by: Dale Newfield

Re: Struts 2 Plug-in and JSP 404
 200614 by: musomesa.aol.com

Re: Actions are not Garbage Collected
 200615 by: musomesa.aol.com

Using Java Generics in Struts Actions
 200616 by: Laetitia DUBY
 200618 by: Dave Newton
 200620 by: Laetitia DUBY

reachable valuestack properties exposed by previous actions?
 200617 by: Dimitrios Christodoulakis
 200619 by: Dave Newton

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)

----------------------------------------------------------------------


Attachment: user_200599.ezm (zipped)

Ajax Validation does not be effective when Action implements Model Driven

but for the action not implements model driven, it works

Validator:

<validators>
<field name="model.account">
<field-validator type="requiredstring">
<message >Account is required!!!</message>
</field-validator>
</field>
</validators>

Action:


public class TestAction extends ActionSupport implements ModelDriven
{
  /**
  * @return user
  */
  public TestUser getUser()
  {
    return user;
  }



  /**
  * @param 对user
  */
  public void setUser(TestUser user)
  {
    this.user = user;
  }



  private TestUser user=new TestUser();
 
 
  public String execute()
  {
    return "success";
  }
 
 
  /**
  * @return
  */
  public Object getModel()
  {
    // TODO Auto-generated method stub
    return this.user;
  }
 
}

JSP:

<%@(protected)"%>
<%@(protected)"%>
<%@(protected)"%>
<html>
<head>
<title></title>
<sx:head debug="true" />
</head>

<body>

<s:form action="test.action" id="form" >
<s:url id="url" action="test.action"/>
<caption><h3>Login</h3></caption>
<s:textfield name="account" label="Account Info" />
<tr>
   <sx:submit key="input.submit" validate="true" />
</tr>
</s:form>
<script type="text/javascript">

</script>
</body>
</html>


Issue1:When i click the button with blank input, it can show the validate
error message
but when I input some message, and click, it still show "required" error
message,
It seemed ajax validation is not effect ed for model driven

Issue2:

When i put File Upload control in jsp and use "required" validation rule,
the submit buttong can not be submited and show error in IE status bar

<s:file name="userDetail" key="input.detail" />

Issue3:

if Datetimepicker Tag set "required" Validation Rule in XML,


When i click submit button, it directly show alert box : Object Error

I have tested other tags,if the tag is assigned "required" validation
rule,it may cause the "Object Error" Javascript alert error in IE6


<field name="model.birthday">
<field-validator type="required">
<message key="birthday.required" />
</field-validator>
<field-validator type="date">
1888-01-01
2008-01-01
<message key="birthday.error" />
</field-validator>
</field>

--
Sent from the Struts - User mailing list archive at Nabble.com.



Attachment: user_200600.ezm (zipped)

  <s:submit type="image" alt="Unlocked" src="/residentrn/images/accept.png"
onclick="%{\"$('\" + #foo + \"').request(); return false;\"}" />




Security Management wrote:
>
> Can someone suggest a way to do this:
>
> <s:submit type="image" alt="Unlocked" src="%{unlocked_image}"
> onclick='$("<s:property value="#foo"/>").request(); return false;'/>
>
> I have tried a bunch of ways, but always wind up with the &lts:property...
> in the resulting HTML, rather than '$("form1").submit()' like I need.
>
> Thanks
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.



Attachment: user_200601.ezm (zipped)
Dear All;
I wnat to validate a String that is similare to "1,102,Y".I was trying to implement it, but it is not working.
     <field property="scheduleDateStr" depends="requiredif">        <arg0 key="label.scheduleDateStr" />        <var>          <var-name>field[0]</var-name>          <var-value>actionType1</var-value>        </var>        <var>          <var-name>fieldValue[0]</var-name>          <var-value>1,102,Y</var-value>        </var>      </field>
Please suggest

With regards and stay in touch ! Allah Hafiz   Muhammad Owais Bilal Awan,
+966-56-5823-940



Attachment: user_200613.ezm (zipped)
Muhammad Owais wrote:
> Dear All;
> I wnat to validate a String that is similare to "1,102,Y".I was trying to implement it, but it is not working.
> <field property="scheduleDateStr" depends="requiredif">
>  <arg0 key="label.scheduleDateStr" />
>  <var>          
>   <var-name>field[0]</var-name>          
>   <var-value>actionType1</var-value>
>  </var>        
>  <var>
>   <var-name>fieldValue[0]</var-name>
>   <var-value>1,102,Y</var-value>
>  </var>
> </field>


Here it looks like you're trying to use "requiredif", which is a
deprecated validator used for conditional validation, to validate the
format of a string, which would normally be handled by a regular
expression (or manual validation) -- the "mask" validator.

Note that "requiredif" is deprecated for "validwhen", but you don't
mention what version of Struts you're using, so I don't know if that's
useful information or not.

Dave


Attachment: user_200602.ezm (zipped)

Hi Musachy,



           I appreciate the assistance, it worked.

-Farshad




> Date: Fri, 10 Jul 2009 13:08:00 -0700
> Subject: Re: assigning a JSP variable a value coming from <s: property>
> From: musachy@(protected)
> To: user@(protected)
>
> do something like:
>
> <s:set var="myId" value="..." scope="page"/>
>
> then in your scriplet, get a reference to the page context (cant
> remember the API) and do a getAttribute("myId") on it.
>
> musachy
>
> On Fri, Jul 10, 2009 at 12:20 PM, Farshad
> Rabbani<farshadrabbani@(protected):
> >
> > Hi Everyone,
> >
> >
> >
> >
> > I am trying to create a java variable in the jsp scriplet and assign it a value coming from <s: property> tag
> >
> > so for example
> >
> > <%
> >
> >       int id = <s: property value="userId"/> ;
> >
> > %>
> >
> >
> >
> > I know the above is completely incorrect, but essentially, that is what I want to accomplish. Can anyone give me any idea how this can be done? Thanks.
> >
> >
> >
> >
> >
> > My action class looks like:
> > public class UserAction extends ActionSupport implements SessionAware, DataSourceAware, UserAware, Preparable, ModelDriven
> > {
> >
> >
> > private User loggedInUser;
> >
> > private Map session;
> > private DataSource dataSource;
> > private int userId;
> >
> >
> >
> >
> > public int getUserId()
> > {
> > return userId;
> > }
> >
> > public void setUserId(int userId)
> > {
> > this.userId = userId;
> > }
> >
> >
> >
> > _________________________________________________________________
> > Hotmail® has ever-growing storage! Don’t worry about storage limits.
> > http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>

_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009

Attachment: user_200603.ezm (zipped)
Hello list,

I am exposing a collection called "entries" in my action class
(Set<JournalEntry> entries;), with all the appropriate getters and
setters. In the result jsp of this action I am using the display tag
to output the content of the collection:

<s:set name="entries" value="entries" scope="request"/>          
   <display:table name="entries" requestURI="">
       <display:column property="entry"/>
       <display:column property="date" sortable="true"
defaultorder="ascending"/>
   </display:table>

But the message I get on the jsp page is: "Nothing found to display".
(Its not an exception, this message is printed on the regulat html
output page). I am certain that the rows exist on the underlying db, I
am using mysql query browser to check.

So, I have followed instructions about struts2 and the display tag
found in different places:
http://www.nabble.com/Struts-2---DisplayTag-example-td17694341.html
http://www.manning-sandbox.com/thread.jspa?messageID=76885
http://appfuse.org/display/APF/Using+Struts+2

But I can't get this simple task to work. The objective is to simply
display the table. In contrast, using just the struts2 tags, the
following works fine:

<table border="3">
     <s:iterator value="entries">
       <tr />
         <td><s:property value="entry"/></td>
         <td><s:property value="date"/></td>
       </tr>
     </s:iterator>
   </table>

However, since I wish to use the display tag for further formatting
and sorting, I was hoping if anyone had any thoughts as to why my code
above finds nothing to display. I can't tell if it finds just an empty
collection, or doesn't find the collection at all.

thanks for any advice.

Regards.


Attachment: user_200604.ezm (zipped)

That sounds like a troubling one, based on what you describe it should work.
Especially if the struts iterator works on the same JSP page.  What version
of Struts and DisplayTag are you using.

There was a time when you had to use the <s:set /> tag and a time when you
did not. Have you tried without the s:set tag?



Dimitrios Christodoulakis wrote:
>
> Hello list,
>
> I am exposing a collection called "entries" in my action class
> (Set<JournalEntry> entries;), with all the appropriate getters and
> setters. In the result jsp of this action I am using the display tag
> to output the content of the collection:
>
> <s:set name="entries" value="entries" scope="request"/>          
>    <display:table name="entries" requestURI="">
>        <display:column property="entry"/>
>        <display:column property="date" sortable="true"
> defaultorder="ascending"/>
>    </display:table>
>
> But the message I get on the jsp page is: "Nothing found to display".
> (Its not an exception, this message is printed on the regulat html
> output page). I am certain that the rows exist on the underlying db, I
> am using mysql query browser to check.
>
> So, I have followed instructions about struts2 and the display tag
> found in different places:
> http://www.nabble.com/Struts-2---DisplayTag-example-td17694341.html
> http://www.manning-sandbox.com/thread.jspa?messageID=76885
> http://appfuse.org/display/APF/Using+Struts+2
>
> But I can't get this simple task to work. The objective is to simply
> display the table. In contrast, using just the struts2 tags, the
> following works fine:
>
> <table border="3">
>      <s:iterator value="entries">
>        <tr />
>          <td><s:property value="entry"/></td>
>          <td><s:property value="date"/></td>
>        </tr>
>      </s:iterator>
>    </table>
>
> However, since I wish to use the display tag for further formatting
> and sorting, I was hoping if anyone had any thoughts as to why my code
> above finds nothing to display. I can't tell if it finds just an empty
> collection, or doesn't find the collection at all.
>
> thanks for any advice.
>
> Regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.



Attachment: user_200605.ezm (zipped)
Yes, thanks for pointing out. The <s:set /> tag is not required so I
removed it and it works. Kind of wondering how the display tag reaches
the valuestack though, or does it access the first property it finds
in the scope?

Thanks

On Sat, Jul 11, 2009 at 12:26 PM, dusty<dustin_pearce@(protected):
>
> That sounds like a troubling one, based on what you describe it should work.
> Especially if the struts iterator works on the same JSP page.   What version
> of Struts and DisplayTag are you using.
>
> There was a time when you had to use the <s:set /> tag and a time when you
> did not.  Have you tried without the s:set tag?
>
>
>
> Dimitrios Christodoulakis wrote:
>>
>> Hello list,
>>
>> I am exposing a collection called "entries" in my action class
>> (Set<JournalEntry> entries;), with all the appropriate getters and
>> setters. In the result jsp of this action I am using the display tag
>> to output the content of the collection:
>>
>> <s:set name="entries" value="entries" scope="request"/>
>>               <display:table name="entries" requestURI="">
>>                       <display:column property="entry"/>
>>                       <display:column property="date" sortable="true"
>> defaultorder="ascending"/>
>>               </display:table>
>>
>> But the message I get on the jsp page is: "Nothing found to display".
>> (Its not an exception, this message is printed on the regulat html
>> output page). I am certain that the rows exist on the underlying db, I
>> am using mysql query browser to check.
>>
>> So, I have followed instructions about struts2 and the display tag
>> found in different places:
>> http://www.nabble.com/Struts-2---DisplayTag-example-td17694341.html
>> http://www.manning-sandbox.com/thread.jspa?messageID=76885
>> http://appfuse.org/display/APF/Using+Struts+2
>>
>> But I can't get this simple task to work. The objective is to simply
>> display the table. In contrast, using just the struts2 tags, the
>> following works fine:
>>
>> <table border="3">
>>                       <s:iterator value="entries">
>>                               <tr />
>>                                       <td><s:property value="entry"/></td>
>>                                       <td><s:property value="date"/></td>
>>                               </tr>
>>                       </s:iterator>
>>               </table>
>>
>> However, since I wish to use the display tag for further formatting
>> and sorting, I was hoping if anyone had any thoughts as to why my code
>> above finds nothing to display. I can't tell if it finds just an empty
>> collection, or doesn't find the collection at all.
>>
>> thanks for any advice.
>>
>> Regards.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/%22Nothing-found-to-display%22-from-display-tag-with-struts-2-tp24441738p24442243.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_200607.ezm (zipped)
On Saturday 11 July 2009 14:02:15 Dimitrios Christodoulakis wrote:
> Yes, thanks for pointing out. The <s:set /> tag is not required so I
> removed it and it works. Kind of wondering how the display tag reaches
> the valuestack though, or does it access the first property it finds
> in the scope?
>

I can't remember the exact details, but I think we wrap the request with a
wrapper class (called StrutsRequestWrapper?) and when ELs and other taglibs
like displaytag want to find values the wrapper will check the value stack in
addition to the traditional locations. It's quite convenient for cases like
you describe.

-Wes
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


Attachment: user_200606.ezm (zipped)
Hello list,

I have successfully used the display tag to iterate over a collection
which is exposed in an action class. On each row in addition to the
columns displaying the fields of each object in the collection, I
embed two more struts-tag urls: Update and Remove.

The objective is to have an extra two columns for every row in the
table giving the ability to update or delete each record:

<display:table name="goalToAchieve.entries" requestURI="" uid="thisGoal">
   <display:column property="entry" />
   <display:column property="date" sortable="true"
defaultorder="ascending" title="TimeStamp"/>
   <display:column><a href="<s:url action='UpdateEntryForm'>
         <s:param name="name" value="%{goalToAchieve.owner.fullName}" />
       </s:url>
       ">Edit</a></display:column>
 <display:column><a href="<s:url action='DeleteEntryForm'>
         <s:param name="name" value="%{goalToAchieve.owner.fullName}" />
         <s:property value="%{entry}"/>
                        </s:url>
            ">Remove</a></display:column>
</display:table>

I am having trouble passing the entry property, (or reference to it)
to the url targeting the update or delete action. The entries
collection consists of value type, embeddable objects. I am aware of
how to pass parameters to the linking url, but my issue is passing a
reference to the "entry" property of each row, to the update or delete
action for the same row.

I hope I am explaining this correctly. The update, or delete jsp forms
will simply display the same entry from the table row, prompting the
user to go ahead with updating or deleting. So these will be
pass-through empty actions to the jsp re-displaying the entry.
Submitting one of these forms will trigger the actual action. My
struts.xml looks like this:

<action name="DeleteEntryForm" >
     <result>/pages/DeleteEntryForm.jsp</result>
</action>
       
<action name="DeleteEntry" class="actions.DeleteEntry">
     <result>/pages/DeleteEntrySuccess.jsp</result>
     <result name="input">/pages/DeleteEntryForm.jsp</result>
</action>

The way I am doing it right now, gives me a NoSuchMethod exception:

WARN OgnlValueStack:49 - Error setting value
ognl.MethodFailedException: Method "setEntry" failed for object
actions.DeleteEntry@(protected):
setEntry([Ljava.lang.String;)]

But in the DeleteEntry class, I have the getters and setters for
entry, and also do a remove from the collection within the execute
method.

Any help is much appreciated


Attachment: user_200608.ezm (zipped)
Hello all, and thank you in advance.

I'm relatively new to struts 2, as I started working with the
framework about 6 months ago on a part time basis. I'm struggling to
solve a problem that I would think would be fairly common: displaying
a tree within a JSP.

Essentially, I have an object (let's call it "Item") that looks
something like the following:

class Item {

  private String name;
  private Set<Item> children;

  // getters and setters
}

Working within a JSP page, I want to display the data within this Item
as follows:

<ul>
  <li>
   <s:property value="item.name"/>
   <s:iterator value="item.children" var="child">
    <ul>
      <li>
       <s:property value="child.name"/>
       <s:iterator value="child.children" var="grandchild">
        <ul>
          <li>
           <s:property value="grandchild.name"/>
           <s:iterator value="grandchild.child" var "greatgrandchild">
            ... and so on
           </s:iterator>
          </li>
        </ul>
       </s:iterator>
      </li>
    </ul>
   </s:iterator>
  </li>
</ul>

Ideally, I would be able to display this data using some sort of
recursion, since there's really no way to tell how deep this tree is.
If anyone knows of a good solution to this problem, I'd be very
interested in hearing it.

I did come up with what I thought might be a solution using the
<s:include> tag. I came up with the following:

In the main jsp page, I have:

<ul>
  <li>
   <s:include value="inc/displayItem.jsp">
    <s:param name="item" value="item"/>
   </s:include>
  </li>
</ul>

In the included jsp page, I have:

<s:property value="item.name"/>
<s:iterator value="item.children" var="child">
  <ul>
   <li>
    <s:include value="inc/displayItem.jsp">
      <s:param name="item" value="child"/>
    </s:include>
   </li>
  </ul>
</s:iterator>

This does not work, of course, because a parameter from within an
included jsp page can only be referenced like this: {$param.item}. In
addition, I can't use that method to access the included parameter
within any struts 2 tags (as far as I can tell).

So again, I suppose my question is: is this an appropriate way of
solving this problem? If so, how can I get this all to work? If not,
what's a better way of going about this?

Thanks again for all of your help,
Anthony Frasso
anf4@(protected)


Attachment: user_200609.ezm (zipped)
Never thought of using a taglib?

Cheers
Avlesh

On Sun, Jul 12, 2009 at 8:49 AM, Anthony Frasso <anf4@(protected):

> Hello all, and thank you in advance.
>
> I'm relatively new to struts 2, as I started working with the
> framework about 6 months ago on a part time basis. I'm struggling to
> solve a problem that I would think would be fairly common: displaying
> a tree within a JSP.
>
> Essentially, I have an object (let's call it "Item") that looks
> something like the following:
>
> class Item {
>
>   private String name;
>   private Set<Item> children;
>
>   // getters and setters
> }
>
> Working within a JSP page, I want to display the data within this Item
> as follows:
>
> <ul>
>   <li>
>    <s:property value="item.name"/>
>    <s:iterator value="item.children" var="child">
>     <ul>
>       <li>
>        <s:property value="child.name"/>
>        <s:iterator value="child.children" var="grandchild">
>         <ul>
>           <li>
>            <s:property value="grandchild.name"/>
>            <s:iterator value="grandchild.child" var
> "greatgrandchild">
>             ... and so on
>            </s:iterator>
>           </li>
>         </ul>
>        </s:iterator>
>       </li>
>     </ul>
>    </s:iterator>
>   </li>
> </ul>
>
> Ideally, I would be able to display this data using some sort of
> recursion, since there's really no way to tell how deep this tree is.
> If anyone knows of a good solution to this problem, I'd be very
> interested in hearing it.
>
> I did come up with what I thought might be a solution using the
> <s:include> tag. I came up with the following:
>
> In the main jsp page, I have:
>
> <ul>
>   <li>
>    <s:include value="inc/displayItem.jsp">
>     <s:param name="item" value="item"/>
>    </s:include>
>   </li>
> </ul>
>
> In the included jsp page, I have:
>
> <s:property value="item.name"/>
> <s:iterator value="item.children" var="child">
>   <ul>
>    <li>
>     <s:include value="inc/displayItem.jsp">
>       <s:param name="item" value="child"/>
>     </s:include>
>    </li>
>   </ul>
> </s:iterator>
>
> This does not work, of course, because a parameter from within an
> included jsp page can only be referenced like this: {$param.item}. In
> addition, I can't use that method to access the included parameter
> within any struts 2 tags (as far as I can tell).
>
> So again, I suppose my question is: is this an appropriate way of
> solving this problem? If so, how can I get this all to work? If not,
> what's a better way of going about this?
>
> Thanks again for all of your help,
> Anthony Frasso
> anf4@(protected)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_200610.ezm (zipped)
Thank you for the quick response Avlesh!

Again, I'm somewhat new to Struts, so I'm not sure I understand your
suggestion. Is there a taglib out there that handles this sort of
thing? Or are you suggesting writing a custom taglib?

Regards,
Anthony Frasso

On Sat, Jul 11, 2009 at 23:22, Avlesh Singh<avlesh@(protected):
> Never thought of using a taglib?
>
> Cheers
> Avlesh
>
> On Sun, Jul 12, 2009 at 8:49 AM, Anthony Frasso <anf4@(protected):
>
>> Hello all, and thank you in advance.
>>
>> I'm relatively new to struts 2, as I started working with the
>> framework about 6 months ago on a part time basis.  I'm struggling to
>> solve a problem that I would think would be fairly common: displaying
>> a tree within a JSP.
>>
>> Essentially, I have an object (let's call it "Item") that looks
>> something like the following:
>>
>> class Item {
>>
>>    private String name;
>>    private Set<Item> children;
>>
>>    // getters and setters
>> }
>>
>> Working within a JSP page, I want to display the data within this Item
>> as follows:
>>
>>  <ul>
>>    <li>
>>      <s:property value="item.name"/>
>>      <s:iterator value="item.children" var="child">
>>        <ul>
>>          <li>
>>            <s:property value="child.name"/>
>>            <s:iterator value="child.children" var="grandchild">
>>              <ul>
>>                <li>
>>                  <s:property value="grandchild.name"/>
>>                  <s:iterator value="grandchild.child" var
>> "greatgrandchild">
>>                    ... and so on
>>                  </s:iterator>
>>                </li>
>>              </ul>
>>            </s:iterator>
>>          </li>
>>        </ul>
>>      </s:iterator>
>>    </li>
>>  </ul>
>>
>> Ideally, I would be able to display this data using some sort of
>> recursion, since there's really no way to tell how deep this tree is.
>> If anyone knows of a good solution to this problem, I'd be very
>> interested in hearing it.
>>
>> I did come up with what I thought might be a solution using the
>> <s:include> tag.  I came up with the following:
>>
>> In the main jsp page, I have:
>>
>>  <ul>
>>    <li>
>>      <s:include value="inc/displayItem.jsp">
>>        <s:param name="item" value="item"/>
>>      </s:include>
>>    </li>
>>  </ul>
>>
>> In the included jsp page, I have:
>>
>>  <s:property value="item.name"/>
>>  <s:iterator value="item.children" var="child">
>>    <ul>
>>      <li>
>>        <s:include value="inc/displayItem.jsp">
>>          <s:param name="item" value="child"/>
>>        </s:include>
>>      </li>
>>    </ul>
>>  </s:iterator>
>>
>> This does not work, of course, because a parameter from within an
>> included jsp page can only be referenced like this: {$param.item}.  In
>> addition, I can't use that method to access the included parameter
>> within any struts 2 tags (as far as I can tell).
>>
>> So again, I suppose my question is: is this an appropriate way of
>> solving this problem?  If so, how can I get this all to work?  If not,
>> what's a better way of going about this?
>>
>> Thanks again for all of your help,
>> Anthony Frasso
>> anf4@(protected)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>


Attachment: user_200611.ezm (zipped)
Yes, I am suggesting to write a custom taglib.

Cheers
Avlesh

On Sun, Jul 12, 2009 at 8:55 AM, Anthony Frasso <anf4@(protected):

> Thank you for the quick response Avlesh!
>
> Again, I'm somewhat new to Struts, so I'm not sure I understand your
> suggestion. Is there a taglib out there that handles this sort of
> thing? Or are you suggesting writing a custom taglib?
>
> Regards,
> Anthony Frasso
>
> On Sat, Jul 11, 2009 at 23:22, Avlesh Singh<avlesh@(protected):
> > Never thought of using a taglib?
> >
> > Cheers
> > Avlesh
> >
> > On Sun, Jul 12, 2009 at 8:49 AM, Anthony Frasso <anf4@(protected)>
> wrote:
> >
> >> Hello all, and thank you in advance.
> >>
> >> I'm relatively new to struts 2, as I started working with the
> >> framework about 6 months ago on a part time basis. I'm struggling to
> >> solve a problem that I would think would be fairly common: displaying
> >> a tree within a JSP.
> >>
> >> Essentially, I have an object (let's call it "Item") that looks
> >> something like the following:
> >>
> >> class Item {
> >>
> >>   private String name;
> >>   private Set<Item> children;
> >>
> >>   // getters and setters
> >> }
> >>
> >> Working within a JSP page, I want to display the data within this Item
> >> as follows:
> >>
> >> <ul>
> >>   <li>
> >>    <s:property value="item.name"/>
> >>    <s:iterator value="item.children" var="child">
> >>     <ul>
> >>       <li>
> >>        <s:property value="child.name"/>
> >>        <s:iterator value="child.children" var="grandchild">
> >>         <ul>
> >>           <li>
> >>            <s:property value="grandchild.name"/>
> >>            <s:iterator value="grandchild.child" var
> >> "greatgrandchild">
> >>             ... and so on
> >>            </s:iterator>
> >>           </li>
> >>         </ul>
> >>        </s:iterator>
> >>       </li>
> >>     </ul>
> >>    </s:iterator>
> >>   </li>
> >> </ul>
> >>
> >> Ideally, I would be able to display this data using some sort of
> >> recursion, since there's really no way to tell how deep this tree is.
> >> If anyone knows of a good solution to this problem, I'd be very
> >> interested in hearing it.
> >>
> >> I did come up with what I thought might be a solution using the
> >> <s:include> tag. I came up with the following:
> >>
> >> In the main jsp page, I have:
> >>
> >> <ul>
> >>   <li>
> >>    <s:include value="inc/displayItem.jsp">
> >>     <s:param name="item" value="item"/>
> >>    </s:include>
> >>   </li>
> >> </ul>
> >>
> >> In the included jsp page, I have:
> >>
> >> <s:property value="item.name"/>
> >> <s:iterator value="item.children" var="child">
> >>   <ul>
> >>    <li>
> >>     <s:include value="inc/displayItem.jsp">
> >>       <s:param name="item" value="child"/>
> >>     </s:include>
> >>    </li>
> >>   </ul>
> >> </s:iterator>
> >>
> >> This does not work, of course, because a parameter from within an
> >> included jsp page can only be referenced like this: {$param.item}. In
> >> addition, I can't use that method to access the included parameter
> >> within any struts 2 tags (as far as I can tell).
> >>
> >> So again, I suppose my question is: is this an appropriate way of
> >> solving this problem? If so, how can I get this all to work? If not,
> >> what's a better way of going about this?
> >>
> >> Thanks again for all of your help,
> >> Anthony Frasso
> >> anf4@(protected)
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@(protected)
> >> For additional commands, e-mail: user-help@(protected)
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_200612.ezm (zipped)
Anthony Frasso wrote:
> ...recursion...
> ...<s:include>...

I'd suggest looking into .tag files:
http://onjava.com/pub/a/onjava/2004/05/12/jsp2part4.html

-Dale


Attachment: user_200614.ezm (zipped)

JSP tags wont't funtion inside jars -- the "JSP"s you might have spotted in jars are probably using Freemarker tags which will work in jars.
Chris







-----Original Message-----
From: Dale Newfield <dale@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Fri, Jul 10, 2009 5:06 am
Subject: Re: Struts 2 Plug-in and JSP 404









stanlick wrote:?

> However, for a plug-in to be a drop-n-go deal, I sort of think the goods?

> should all be in the plug-in jar itself? Make sense??
?

Agreed, but I believe I've been told that can't be done with jsp
templates. This is why plugins that I've seen have been implemented in
freemarker.?
?

> I was looking at this?

> article, and it appears this cat has a JSP working in his plug-in??

>
> http://www.struts2.org/category/struts2-plugins/?
?

I downloaded that zip, and looked inside the .jars: no .jsps.?
?

> The reason for this plug-in is to eliminate a couple pages of configuration?

> steps for the adopter of my application. I'd rather not say just drop the?

> plug-in in your WEB-INF/lib folder and then copy JSP files here...?
?

I'm simply reporting hear-say here, but I believe you've already hit the
roadblock that'll prevent you from getting farther w/o using a different
template engine.?
?

-Dale?
?

---------------------------------------------------------------------?

To unsubscribe, e-mail: user-unsubscribe@(protected)?

For additional commands, e-mail: user-help@(protected)?
?






Attachment: user_200615.ezm (zipped)

It is unlikely but if your actions have a finalize() method they won't be collected by minor GCs
Chris







-----Original Message-----
From: Anselmo <anselm.bauer@(protected)>
To: user@(protected)
Sent: Sat, Jul 11, 2009 2:55 am
Subject: Re: Actions are not Garbage Collected











The only references I have to my action are

localeProvider of com.opensymphony.xwork2.TextProviderSupport

which has references from the action again. Is this maybe running in
circles?
--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)







Attachment: user_200616.ezm (zipped)
Hi all !

I'm new to Struts2 and I'm starting with implementing a simple app. So
far, everything was fine. But now I want to complexify a bit by
introducing java generics (to prevent from repeating same treatments
in several classes) and integrating with Spring.

I tried writing a GenericAction which has 2 parameterized type (one
for the service used, one for the generated object from the form) and
which contains all basic methods for saving, deleting, updating,
listing objects (but with parameterized types). Then I wrote an action
which extends this GenericAction, the 2 types are passed in argument
in the extends statement.

The struts.xml config file references the later one and I have an
additional constant declaration to use Spring : <constant
name="struts.objectFactory" value="spring" />.

When I fill in the form and call the save.action, I get the following
error: ognl.NoSuchPropertyException: java.lang.Object.id

This tells me that Struts (or Spring) do not create the right type of
object and is then not capable to set the properties. But I don't
understand why. I tested the generics principle with simple classes
(MyBox extends Box<Integer>, where Box<T> is a generic class) and when
I create a MyBox object in a main function, the property has the right
type (Integer).

Can you help me to point out where is the problem ? Am i missing
something with the generics or is it a configuration problem with
Struts (or Spring) ?

Many thanks in advance for your help.

Laëtitia


Attachment: user_200618.ezm (zipped)
You don't describe the circumstances under which you get the error, so
it's difficult to help. It might just be OGNL's result vs. action
property thing, which is ignorable.

Dave

Laetitia DUBY wrote:
> Hi all !
>
> I'm new to Struts2 and I'm starting with implementing a simple app. So
> far, everything was fine. But now I want to complexify a bit by
> introducing java generics (to prevent from repeating same treatments
> in several classes) and integrating with Spring.
>
> I tried writing a GenericAction which has 2 parameterized type (one
> for the service used, one for the generated object from the form) and
> which contains all basic methods for saving, deleting, updating,
> listing objects (but with parameterized types). Then I wrote an action
> which extends this GenericAction, the 2 types are passed in argument
> in the extends statement.
>
> The struts.xml config file references the later one and I have an
> additional constant declaration to use Spring : <constant
> name="struts.objectFactory" value="spring" />.
>
> When I fill in the form and call the save.action, I get the following
> error: ognl.NoSuchPropertyException: java.lang.Object.id
>
> This tells me that Struts (or Spring) do not create the right type of
> object and is then not capable to set the properties. But I don't
> understand why. I tested the generics principle with simple classes
> (MyBox extends Box<Integer>, where Box<T> is a generic class) and when
> I create a MyBox object in a main function, the property has the right
> type (Integer).
>
> Can you help me to point out where is the problem ? Am i missing
> something with the generics or is it a configuration problem with
> Struts (or Spring) ?
>
> Many thanks in advance for your help.
>
> Laëtitia
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_200620.ezm (zipped)
On Sun, Jul 12, 2009 at 3:20 PM, Dave Newton<newton.dave@(protected):
> You don't describe the circumstances under which you get the error, so it's
> difficult to help. It might just be OGNL's result vs. action property thing,
> which is ignorable.
I am not sure what you mean by circumstances, so I'll add all the
relevant part of my code.

First, I have a jsp with a form, using struts taglib :
<s:form action="save" validate="true">
  <s:textfield id="id" name="entity.id" cssStyle="display:none"/>
  <s:textfield id="titre" label="Titre" name="entity.titre"/>
  <s:textfield id="sujet" label="Sujet" name="entity.sujet"/>
  <s:textfield id="texte" label="Texte" name="entity.texte"/>
  <sx:submit targets="automaticAnswers" notifyTopics="/save"/>
</s:form>

The target action is AutomaticAnswerAction, and should use an "entity"
of type "ReponseAutomatique" (but that's the problem, at runtime it is
only of type "Object") :
public class AutomaticAnswerAction extends
GenericAction<ReponseAutomatique, AutomaticAnswer> {
}

AutomaticAnswerAction inherits from the generic class GenericAction :
public abstract class GenericAction<T, S extends GenericService<T>>
implements Preparable {
  private S service;
  private List<T> entities;
  public T entity;
  private Integer id;
[...]
  public T getEntity() {
    return entity;
  }

  public void setEntity(T entity) {
    this.entity = (T) entity;
  }
}

The fields from the form are related to an object of type
ReponseAutomatique (hence the try to use
GenericAction<ReponseAutomatique, AutomaticAnswer>), but when I use
the debugger I can see that the object is only of type "Object", so I
get the error below :
error: ognl.NoSuchPropertyException: java.lang.Object.id

Of course, Object has no property id, but ReponseAutomatique has one.

The struts.xml (not relevant I guess in this case) :
<action name="save" class="automaticAnswerAction" method="save">
  <result>pages/parameter/automaticAnswer/list.jsp</result>
  <result name="input">pages/parameter/automaticAnswer/list.jsp</result>
</action>

I am not sure wether we can use the generics at all in this case : I
believe there is only servlet instanciated, so that would mean to
change the type of the object at runtime, and that is not possible, as
the java generics are used only at compile time.

Thanks for your help,

Laetitia



> Laetitia DUBY wrote:
>>
>> Hi all !
>>
>> I'm new to Struts2 and I'm starting with implementing a simple app. So
>> far, everything was fine. But now I want to complexify a bit by
>> introducing java generics (to prevent from repeating same treatments
>> in several classes) and integrating with Spring.
>>
>> I tried writing a GenericAction which has 2 parameterized type (one
>> for the service used, one for the generated object from the form) and
>> which contains all basic methods for saving, deleting, updating,
>> listing objects (but with parameterized types). Then I wrote an action
>> which extends this GenericAction, the 2 types are passed in argument
>> in the extends statement.
>>
>> The struts.xml config file references the later one and I have an
>> additional constant declaration to use Spring : <constant
>> name="struts.objectFactory" value="spring" />.
>>
>> When I fill in the form and call the save.action, I get the following
>> error: ognl.NoSuchPropertyException: java.lang.Object.id
>>
>> This tells me that Struts (or Spring) do not create the right type of
>> object and is then not capable to set the properties. But I don't
>> understand why. I tested the generics principle with simple classes
>> (MyBox extends Box<Integer>, where Box<T> is a generic class) and when
>> I create a MyBox object in a main function, the property has the right
>> type (Integer).
>>
>> Can you help me to point out where is the problem ? Am i missing
>> something with the generics or is it a configuration problem with
>> Struts (or Spring) ?
>>
>> Many thanks in advance for your help.
>>
>> Laėtitia
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_200617.ezm (zipped)
Hello,

This is a quick question that I am having, more on the theory side.
So, what happens to properties exposed on the valuestack by some
action which was called in the past, meaning the application workflow
has progressed and other actions were called after that. Is that
property somehow still reachable on the stack (by other actions and
action results), or is it popped from the stack as soon as another
action is called?

For example, I need to access a property exposed a few actions back,
and was wondering what is the appropriate way to do that. Can I
somehow propagate (or carry over) this property through actions and
results (would like to avoid attaching it to url params) until I am
ready to use it, or can it just sit there and be retrieved by digging
deep into the valuestack? Is there a handy example somewhere?

At the same time I am consulting my struts 2 book to grasp the idea,
but any hint to help me understand this better would be greatly
appreciated.

Regards


Attachment: user_200619.ezm (zipped)
Dimitrios Christodoulakis wrote:
> This is a quick question that I am having, more on the theory side.
> So, what happens to properties exposed on the valuestack by some
> action which was called in the past, meaning the application workflow
> has progressed and other actions were called after that. Is that
> property somehow still reachable on the stack (by other actions and
> action results), or is it popped from the stack as soon as another
> action is called?

If you're not using action chaining the stack is popped between requests.

Dave

©2008 gg3721.com - Jax Systems, LLC, U.S.A.