You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sr...@chennai.tcs.co.in on 2003/08/19 13:07:59 UTC

Security and Roles related

Does STRUTS provide integration with any security framework independent of
the underlying application server. Basically I am looking at services like
isUserInRole(), getRole() and the sort.

Regards
Sreekant G
@ 98404-65630



RE: Indexed property names - the real story

Posted by Richard Mixon <rn...@custco.biz>.
Linda,

Thanks - that cleared things up. Things are working great now that I let the
indexed methods use a different name. Many of the examples and howtos on
indexed properties are not at all clear on this.

The list methods turn out to only be needed by my action class, so the fact
that their names do not correspond to the the property= name on my JSP does
not really matter.

 - Richard



 -----Original Message-----
From: Lynda Brown [mailto:greensparks828@yahoo.com]
Sent: Wednesday, August 20, 2003 11:40 AM
To: Struts Users Mailing List; rnmixon@custco.biz
Subject: Re: Indexed property names - the real story


The problem is that you end up having two identically named methods that
return different types.  How is the compiler supposed to know which one to
use?  I had this same problem myself for a while, because you are right that
is what seems to follow JavaBean specs.  But your solution is exactly what
you should do, you are still following spec because you do have a getter
method with the correct name.  You just also have an additional getter
method to return one within the List.  I think this answers your question.

:)

Richard Mixon <rn...@custco.biz> wrote:
  First, sorry for the long posting - it shorter than a few, but not many
:).

  I've read a number of very good postings on the list on how to handle
  indexed properties using the "having a bit of a problem determining what
the corresponding getter/setter
  names should be.

  The problem is naming of the getter for my list of line items. At first I
  had the following signatures

  // First to get and set the entire list
  public List getCurrLineItems() ...
  public void setCurrLineItems(List lineItems) ...

  // Next to get and set individual indexed items in the list
  public LineItem getCurrLineItems(int liDex) ...
  public void setCurrLineItems(int liDex, LineItem lineItem) ...

  With the indexed getter/setters as above, it does not work. However, if I
  name them differently from the List getter/setters they work (for example
  names then getCurrentLineItems and setCurrentLineItems instead of
  getCurrLineItems and setCurrLineItems). This appears to be contrary to all
  of the examples I can find and the JavaBeans spec. Before proceeding I
want
  to clear this up.

  With the matching names for indexed properties I could not get my JSP page
  to see the line items. I tried the "logic:iterate", "nested:iterate" and
  "logic-el:iterate" variations of the Struts iterate tag. I also tried
using
  a JSTL "


  Existing Line Items



       Delete




       key="formLineItemsForm.status"/>
        Act  Inact


    property="currLineItems" indexId="mpDex">

       property="deleteXMP[${mpDex}]" value="true" title="Check to delete
and press
        Change"/>

        property="name" size="24" maxlength="24" indexed="true"/>

        indexed="true">
        labelProperty="name"/>


        size="1" maxlength="2" indexed="true" />

        value="1" indexed="true"/> property="status_id" value="2"
indexed="true"/>

        indexed="true"/>
        indexed="true"/>
        indexed="true"/>









  ...
  JSP - fragment - END


  FormBean - BEGIN
  public class OrderLineForm extends com.ltoj.webapp.form.BaseForm
implements
  java.io.Serializable {

  private OrderForm base = new OrderForm();
  private List deleteXMP = new ArrayList();
  private List currLineItems = new ArrayList();
  private List newLineItems = new ArrayList(1);

  public OrderForm getBase() { return base; }

  public void setBase(OrderForm subject) { this.base = subject; }

  /**
  * Flags, set if corresponding existing line item should be deleted.
  */
  public List getDeleteXMP() { return deleteXMP; }
  public String getDeleteXMP(int mpDex) { return
  (String)this.deleteXMP.get(mpDex); }

  public void setDeleteXMP(List deleteXMP) { this.deleteXMP = deleteXMP; }
  public void setDeleteXMP(int mpDex, String deleteXMP) {
  this.deleteXMP.add(deleteXMP); }

  public List getCurrLineItems() { return this.currLineItems; }
  public LineItemsForm getCurrMeasurementParms(int mpDex) { return
  (LineItemsForm)this.currLineItems.get(mpDex); }

  public void setCurrLineItems( List currLineItems ) { this.currLineItems
  = currLineItems; }
  public void setCurrMeasurementParms( int mpDex, LineItemsForm
  currLineItem ) { this.currLineItems.add(currLineItem); }

  public List getNewLineItems() { return this.newLineItems; }
  public LineItemsForm getNewMeasurementParms(int mpDex) { return
  (LineItemsForm)this.newLineItems.get(mpDex); }

  public void setNewLineItems( List newLineItems ) { this.newLineItems =
  newLineItems; }
  public void setNewMeasurementParms( int mpDex, LineItemsForm
  newLineItem ) { this.newLineItems.add(newLineItem); }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
  base = new OrderForm();
  deleteXMP = new ArrayList();
  currLineItems = new ArrayList();
  newLineItems = new ArrayList(1);
  }
  }
  FormBean - END



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


----------------------------------------------------------------------------
----
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Re: Indexed property names - the real story

Posted by Lynda Brown <gr...@yahoo.com>.
The problem is that you end up having two identically named methods that return different types.  How is the compiler supposed to know which one to use?  I had this same problem myself for a while, because you are right that is what seems to follow JavaBean specs.  But your solution is exactly what you should do, you are still following spec because you do have a getter method with the correct name.  You just also have an additional getter method to return one within the List.  I think this answers your question.
 
:)

Richard Mixon <rn...@custco.biz> wrote: 
First, sorry for the long posting - it shorter than a few, but not many :).

I've read a number of very good postings on the list on how to handle
indexed properties using the "having a bit of a problem determining what the corresponding getter/setter
names should be.

The problem is naming of the getter for my list of line items. At first I
had the following signatures

// First to get and set the entire list
public List getCurrLineItems() ...
public void setCurrLineItems(List lineItems) ...

// Next to get and set individual indexed items in the list
public LineItem getCurrLineItems(int liDex) ...
public void setCurrLineItems(int liDex, LineItem lineItem) ...

With the indexed getter/setters as above, it does not work. However, if I
name them differently from the List getter/setters they work (for example
names then getCurrentLineItems and setCurrentLineItems instead of
getCurrLineItems and setCurrLineItems). This appears to be contrary to all
of the examples I can find and the JavaBeans spec. Before proceeding I want
to clear this up.

With the matching names for indexed properties I could not get my JSP page
to see the line items. I tried the "logic:iterate", "nested:iterate" and
"logic-el:iterate" variations of the Struts iterate tag. I also tried using
a JSTL "


Existing Line Items



Delete
    



key="formLineItemsForm.status"/>
Act  Inact

property="currLineItems" indexId="mpDex">

property="deleteXMP[${mpDex}]" value="true" title="Check to delete and press
Change"/>
 
property="name" size="24" maxlength="24" indexed="true"/>

indexed="true">
labelProperty="name"/>


size="1" maxlength="2" indexed="true" />

value="1" indexed="true"/> property="status_id" value="2" indexed="true"/>

indexed="true"/>
indexed="true"/>
indexed="true"/>








...
JSP - fragment - END


FormBean - BEGIN
public class OrderLineForm extends com.ltoj.webapp.form.BaseForm implements
java.io.Serializable {

private OrderForm base = new OrderForm();
private List deleteXMP = new ArrayList();
private List currLineItems = new ArrayList();
private List newLineItems = new ArrayList(1);

public OrderForm getBase() { return base; }

public void setBase(OrderForm subject) { this.base = subject; }

/**
* Flags, set if corresponding existing line item should be deleted.
*/
public List getDeleteXMP() { return deleteXMP; }
public String getDeleteXMP(int mpDex) { return
(String)this.deleteXMP.get(mpDex); }

public void setDeleteXMP(List deleteXMP) { this.deleteXMP = deleteXMP; }
public void setDeleteXMP(int mpDex, String deleteXMP) {
this.deleteXMP.add(deleteXMP); }

public List getCurrLineItems() { return this.currLineItems; }
public LineItemsForm getCurrMeasurementParms(int mpDex) { return
(LineItemsForm)this.currLineItems.get(mpDex); }

public void setCurrLineItems( List currLineItems ) { this.currLineItems
= currLineItems; }
public void setCurrMeasurementParms( int mpDex, LineItemsForm
currLineItem ) { this.currLineItems.add(currLineItem); }

public List getNewLineItems() { return this.newLineItems; }
public LineItemsForm getNewMeasurementParms(int mpDex) { return
(LineItemsForm)this.newLineItems.get(mpDex); }

public void setNewLineItems( List newLineItems ) { this.newLineItems =
newLineItems; }
public void setNewMeasurementParms( int mpDex, LineItemsForm
newLineItem ) { this.newLineItems.add(newLineItem); }

public void reset(ActionMapping mapping, HttpServletRequest request) {
base = new OrderForm();
deleteXMP = new ArrayList();
currLineItems = new ArrayList();
newLineItems = new ArrayList(1);
}
}
FormBean - END



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




---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Indexed property names - the real story

Posted by Richard Mixon <rn...@custco.biz>.
First, sorry for the long posting - it shorter than a few, but not many :).

I've read a number of very good postings on the list on how to handle
indexed properties using the "<logic:iterate" tag. In spite of this I'm
having a bit of a problem determining what the corresponding getter/setter
names should be.

The problem is naming of the getter for my list of line items. At first I
had the following signatures

  // First to get and set the entire list
  public List getCurrLineItems() ...
  public void setCurrLineItems(List lineItems) ...

  // Next to get and set individual indexed items in the list
  public LineItem getCurrLineItems(int liDex) ...
  public void setCurrLineItems(int liDex, LineItem lineItem) ...

With the indexed getter/setters as above, it does not work. However, if I
name them differently from the List getter/setters they work (for example
names then getCurrentLineItems and setCurrentLineItems instead of
getCurrLineItems and setCurrLineItems). This appears to be contrary to all
of the examples I can find and the JavaBeans spec. Before proceeding I want
to clear this up.

With the matching names for indexed properties I could not get my JSP page
to see the line items. I tried the "logic:iterate", "nested:iterate" and
"logic-el:iterate" variations of the Struts iterate tag. I also tried using
a JSTL "<c:forEach " loop.
In my action, I set the form bean in the request, could print the form bean
and see all of the line items, . But when it got to the JSP page, BeanUtils
said there currLineItems property was empty.

After deciding that there might be a problem with my property names
(grasping at straws), I discovered that using different names for the
indexed methods seems to have fixed things.

Any ideas on why this is happening. Better yet, how should things work?

I've cut down a piece of my JSP page and my form bean below, trying to keep
enough info without making it too long to read.

JSP - fragment - BEGIN
<logic:present name="orderLineForm">
  <logic:present name="orderLineForm" property="currLineItems">
    <logic:notEmpty name="orderLineForm" property="currLineItems">
  <tr><td colspan="4" width="725">Existing Line Items</td></tr>
  <tr><td colspan="4" width="725">
      <table>
        <tr>
          <th>Delete</th>
          <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
          <th><bean:message key="formLineItemsForm.name"/></th>
          <th><bean:message key="formLineItemsForm.measurementUnit"/></th>
          <th><bean:message key="formLineItemsForm.displayDecimals"/></th>
          <th ><bean:message
key="formLineItemsForm.status"/><br>Act&nbsp;&nbsp;Inact</th>
        </tr>
      <nested:iterate id="currLineItems" name="orderLineForm"
property="currLineItems" indexId="mpDex">
        <tr>
          <td><html-el:checkbox name="orderLineForm"
property="deleteXMP[${mpDex}]" value="true" title="Check to delete and press
Change"/></td>
          <td>&nbsp;</td>
          <td>                           <nested:text name="currLineItems"
property="name"               size="24" maxlength="24" indexed="true"/></td>
          <td>
            <html:select name="currLineItems" property="measurementUnit_id"
indexed="true">
              <html:options collection="measurementUnits" property="id"
labelProperty="name"/>
            </html:select>
          </td>
          <td ><nested:text name="currLineItems" property="displayDecimals"
size="1"  maxlength="2" indexed="true" /></td>
          <td>
            <nested:radio name="currLineItems" property="status_id"
value="1" indexed="true"/>&nbsp;<nested:radio name="currLineItems"
property="status_id" value="2" indexed="true"/>
          </td>
          <td><nested:hidden name="currLineItems" property="measurementUnit"
indexed="true"/></td>
          <td><nested:hidden name="currLineItems" property="order"
indexed="true"/></td>
          <td><nested:hidden name="currLineItems" property="order_id"
indexed="true"/></td>
        </tr>
      </nested:iterate>
      </table>
    </td>
  </tr>
    </logic:notEmpty>
  </logic:present>
</logic:present>
...
JSP - fragment - END


FormBean - BEGIN
public class OrderLineForm extends com.ltoj.webapp.form.BaseForm implements
java.io.Serializable {

    private OrderForm base = new OrderForm();
    private List deleteXMP = new ArrayList();
    private List currLineItems = new ArrayList();
    private List newLineItems = new ArrayList(1);

    public OrderForm getBase() { return base; }

    public void setBase(OrderForm subject) { this.base = subject; }

    /**
     *  Flags, set if corresponding existing line item should be deleted.
     */
    public List getDeleteXMP() { return deleteXMP; }
    public String getDeleteXMP(int mpDex) { return
(String)this.deleteXMP.get(mpDex); }

    public void setDeleteXMP(List deleteXMP) { this.deleteXMP = deleteXMP; }
    public void setDeleteXMP(int mpDex, String deleteXMP) {
this.deleteXMP.add(deleteXMP); }

    public List getCurrLineItems() { return this.currLineItems; }
    public LineItemsForm getCurrMeasurementParms(int mpDex) { return
(LineItemsForm)this.currLineItems.get(mpDex); }

    public void setCurrLineItems( List currLineItems ) { this.currLineItems
= currLineItems; }
    public void setCurrMeasurementParms( int mpDex, LineItemsForm
currLineItem ) { this.currLineItems.add(currLineItem); }

    public List getNewLineItems() { return this.newLineItems; }
    public LineItemsForm getNewMeasurementParms(int mpDex) { return
(LineItemsForm)this.newLineItems.get(mpDex); }

    public void setNewLineItems( List newLineItems ) { this.newLineItems =
newLineItems; }
    public void setNewMeasurementParms( int mpDex, LineItemsForm
newLineItem ) { this.newLineItems.add(newLineItem); }

    public void reset(ActionMapping mapping, HttpServletRequest request) {
          base = new OrderForm();
          deleteXMP = new ArrayList();
          currLineItems = new ArrayList();
          newLineItems = new ArrayList(1);
    }
}
FormBean - END



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


Re: Security and Roles related

Posted by Max Cooper <ma...@maxcooper.com>.
You can use Struts with SecurityFilter, which is a filter-based system
designed initially to work just like container-managed security, with a few
extensions.

http://www.securityfilter.org/

-Max

----- Original Message ----- 
From: <sr...@chennai.tcs.co.in>
To: <st...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 4:07 AM
Subject: Security and Roles related


> Does STRUTS provide integration with any security framework independent of
> the underlying application server. Basically I am looking at services like
> isUserInRole(), getRole() and the sort.
>
> Regards
> Sreekant G
> @ 98404-65630
>
>
>


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


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



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


Re: Security and Roles related

Posted by Dan Tran <da...@hotmail.com>.
You can assign a role attribute with multiple role names in the action
configuration.

Underneath, struts uses isUserInRole to check against the list you provided.

However, checking security is better off to let container do it for you.

-D

----- Original Message ----- 
From: <sr...@chennai.tcs.co.in>
To: <st...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 4:07 AM
Subject: Security and Roles related


> Does STRUTS provide integration with any security framework independent of
> the underlying application server. Basically I am looking at services like
> isUserInRole(), getRole() and the sort.
>
> Regards
> Sreekant G
> @ 98404-65630
>
>
>


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


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

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


RE: Security and Roles related

Posted by Navjot Singh <na...@net4india.net>.
struts provide support for JAAS and JAAS further supports the security roles
and accesses independent of mechanisms.
will that do?

hth
-navjot

|-----Original Message-----
|From: sreekant_gottimukkala@chennai.tcs.co.in
|[mailto:sreekant_gottimukkala@chennai.tcs.co.in]
|Sent: Tuesday, August 19, 2003 4:38 PM
|To: struts-user@jakarta.apache.org
|Subject: Security and Roles related
|
|
|Does STRUTS provide integration with any security framework independent of
|the underlying application server. Basically I am looking at services like
|isUserInRole(), getRole() and the sort.
|
|Regards
|Sreekant G
|@ 98404-65630
|
|
|


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