Re: [REPOST] Best Practice Question - html links
Thanks Kris, That worked beautifully, I've been pulling my hair over that one for 3 days now Thanks again Joanne Corless CSC Computer Sciences Limited ( Office +44 (0)1772 318025 ( Mobile +44 (0)7767 656588 * email [EMAIL PROTECTED] Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN CSC Computer Sciences Limited: Registered in England, No. 963578. Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire, GU11 1PZ. This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[REPOST] Best Practice Question - html links
I know this may seem a little rude but no-one picked up on my question and I really could use some help with this Regards Joanne Corless - Forwarded by Joanne L Corless/UK/CSC on 14/10/03 13:36 - Joanne L Corless /UK/CSC To: [EMAIL PROTECTED] cc: 13/10/03 17:12 Subject: Best Practice Question re: html links Hi, I am implementing a struts application with menu lists which need to be dynamic based on a user role hierarchy, i.e not a simple user role = menu list. Therefore I cannot set up menu lists in the tile definitions file as they are I hold the menu list in a database which I am accessing via an EJB and returning to the session using a vector of DAO object 's which contain the basic information about each menu item, i.e name, link,type (we have different types of links some open a pop-up window, others run an inline java applet) Currently I am using standard Java scriptlets to access the vector and print it out in the JSP tile page example below: %@ page contentType=text/html;charset=UTF-8 language=java % %@ taglib uri=/struts/tiles prefix=tiles % %@ taglib uri=/struts/logic prefix=logic % %@ taglib uri=/struts/bean prefix=bean % %@ taglib uri=/struts/html prefix=html % %@ page import=com.csc.ebilling.ejb.common.MenuItemDAO % % String commonImagePath= request.getContextPath() +/presentation/DEFAULT/images; String currentPageName = (String)session.getAttribute (currentPageName); java.util.Vector topMenu = (java.util.Vector) session.getAttribute (topMenu); % table tr % for (int i=0;itopMenu.size();i++){ // pageContext.setAttribute(topMenuItem, topMenuItem, PageContext.PAGE_SCOPE); MenuItemDAO topMenuItem = (MenuItemDAO) topMenu.get(i); if (topMenuItem.getMenuItemName().equals(currentPageName)) { % td valign=bottom align=right class=tabselected img src=%=commonImagePath%/page_name_left_selected.gif border=0 /td td valign=bottom background= %=commonImagePath%/page_name_mid_selected.gif align=center class =tabselected nowrap style=background-repeat: repeat-x; span class=tabselected%=topMenuItem.getMenuItemName()%/span /td td valign=bottom align=left class=tabselected img src=%=commonImagePath%/page_name_right_selected.gif border =0 /td % } else { % td valign=bottom align=right class=tabunselected a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% img src=%=commonImagePath%/page_name_left_unselected.gif border=0 /a /td td valign=bottom background= %=commonImagePath%/page_name_mid_unselected.gif align=center class =tabunselected nowrap style=background-repeat: repeat-x; a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% span class=tabunselected%=topMenuItem.getMenuItemName ()%/span /a /td td valign=bottom align=left class=tabunselected a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% img src=%=commonImagePath%/page_name_right_unselected.gif border=0 /a /td % } } % /tr /table I realise that this is not best practice and I should be using the tag-libs but I'm struggling to make the tag-libs work, I'm also confused about whether this tile needs to be inside a form as I am not actually submitting anything (as in a Login page), however I do need to pass a pageName parameter into the request. The above example does work (sort of) however I am unable to extract the pageName parameter in my action class as it keeps returning null I would really appreciate some pointers as I thought I had struts figured but I now realise I've gone wrong somewhere along the line Regards Joanne Corless CSC Computer Sciences Limited ( Office +44 (0)1772 318025 ( Mobile +44 (0)7767 656588 * email [EMAIL PROTECTED] Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN CSC Computer Sciences Limited: Registered in England, No. 963578. Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire, GU11 1PZ
Re: [REPOST] Best Practice Question - html links
If you're using a JSP 1.2 container, JSTL can help out a bit. It doesn't look like you need an HTML form for any of this, you're constructing a bunch of links that will issue GETs to the action mapped to /changePage. As long as that mapping uses a (Struts) form with a property called pageName, it should work. struts-config: form-bean name=changePageForm type=org.apache.struts.action.DynaActionForm form-property name=pageName type=java.lang.String/ /form-bean action path=/changePage type=com.csc.ebilling.actions.ChangePageAction name=changePageForm scope=request validate=false/ JSP: %@ page pageEncoding=UTF-8 % %@ taglib prefix=curi=http://java.sun.com/jstl/core; % %@ taglib prefix=html uri=http://jakarta.apache.org/struts/tags-html; % c:set var=commonImagePath value=${pageContext.request.contextPath}/presentation/DEFAULT/images/ c:set var=currentPageName value=${sessionScope.currentPageName}/ c:set var=topMenu value=${sessionScope.topMenu}/ table tr c:forEach var=topMenuItem items=${topMenu} c:choose c:when test=${topMenuItem.menuItemName eq currentPageName} td valign=bottom align=right class=tabselected img src=c:out value=${commonImagePath}/page_name_left_selected.gif/ border=0 /td ... /c:when c:otherwise td valign=bottom align=right class=tabunselected html:link action=/changePage paramId=pageName paramName=topMenuItem paramProperty=menuItemName img src=c:out value=${commonImagePath}/page_name_left_unselected.gif/ border=0 /html:link /td ... /c:otherwise c:choose /c:forEach /tr /table Quoting Joanne L Corless [EMAIL PROTECTED]: I know this may seem a little rude but no-one picked up on my question and I really could use some help with this Regards Joanne Corless - Forwarded by Joanne L Corless/UK/CSC on 14/10/03 13:36 - Joanne L Corless /UK/CSC To: [EMAIL PROTECTED] cc: 13/10/03 17:12 Subject: Best Practice Question re: html links Hi, I am implementing a struts application with menu lists which need to be dynamic based on a user role hierarchy, i.e not a simple user role = menu list. Therefore I cannot set up menu lists in the tile definitions file as they are I hold the menu list in a database which I am accessing via an EJB and returning to the session using a vector of DAO object 's which contain the basic information about each menu item, i.e name, link,type (we have different types of links some open a pop-up window, others run an inline java applet) Currently I am using standard Java scriptlets to access the vector and print it out in the JSP tile page example below: %@ page contentType=text/html;charset=UTF-8 language=java % %@ taglib uri=/struts/tiles prefix=tiles % %@ taglib uri=/struts/logic prefix=logic % %@ taglib uri=/struts/bean prefix=bean % %@ taglib uri=/struts/html prefix=html % %@ page import=com.csc.ebilling.ejb.common.MenuItemDAO % % String commonImagePath= request.getContextPath() +/presentation/DEFAULT/images; String currentPageName = (String)session.getAttribute (currentPageName); java.util.Vector topMenu = (java.util.Vector) session.getAttribute (topMenu); % table tr % for (int i=0;itopMenu.size();i++){ // pageContext.setAttribute(topMenuItem, topMenuItem, PageContext.PAGE_SCOPE); MenuItemDAO topMenuItem = (MenuItemDAO) topMenu.get(i); if (topMenuItem.getMenuItemName().equals(currentPageName)) { % td valign=bottom align=right class=tabselected img src=%=commonImagePath%/page_name_left_selected.gif border=0 /td td valign=bottom background= %=commonImagePath%/page_name_mid_selected.gif align=center class =tabselected nowrap style=background-repeat: repeat-x; span class=tabselected%=topMenuItem.getMenuItemName()%/span /td td valign=bottom align=left class=tabselected img src=%=commonImagePath
Best Practice Question re: html links
Hi, I am implementing a struts application with menu lists which need to be dynamic based on a user role hierarchy, i.e not a simple user role = menu list. Therefore I cannot set up menu lists in the tile definitions file as they are I hold the menu list in a database which I am accessing via an EJB and returning to the session using a vector of DAO object 's which contain the basic information about each menu item, i.e name, link,type (we have different types of links some open a pop-up window, others run an inline java applet) Currently I am using standard Java scriptlets to access the vector and print it out in the JSP tile page example below: %@ page contentType=text/html;charset=UTF-8 language=java % %@ taglib uri=/struts/tiles prefix=tiles % %@ taglib uri=/struts/logic prefix=logic % %@ taglib uri=/struts/bean prefix=bean % %@ taglib uri=/struts/html prefix=html % %@ page import=com.csc.ebilling.ejb.common.MenuItemDAO % % String commonImagePath= request.getContextPath() +/presentation/DEFAULT/images; String currentPageName = (String)session.getAttribute (currentPageName); java.util.Vector topMenu = (java.util.Vector) session.getAttribute (topMenu); % table tr % for (int i=0;itopMenu.size();i++){ // pageContext.setAttribute(topMenuItem, topMenuItem, PageContext.PAGE_SCOPE); MenuItemDAO topMenuItem = (MenuItemDAO) topMenu.get(i); if (topMenuItem.getMenuItemName().equals(currentPageName)) { % td valign=bottom align=right class=tabselected img src=%=commonImagePath%/page_name_left_selected.gif border=0 /td td valign=bottom background= %=commonImagePath%/page_name_mid_selected.gif align=center class =tabselected nowrap style=background-repeat: repeat-x; span class=tabselected%=topMenuItem.getMenuItemName()%/span /td td valign=bottom align=left class=tabselected img src=%=commonImagePath%/page_name_right_selected.gif border =0 /td % } else { % td valign=bottom align=right class=tabunselected a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% img src=%=commonImagePath%/page_name_left_unselected.gif border=0 /a /td td valign=bottom background= %=commonImagePath%/page_name_mid_unselected.gif align=center class =tabunselected nowrap style=background-repeat: repeat-x; a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% span class=tabunselected%=topMenuItem.getMenuItemName ()%/span /a /td td valign=bottom align=left class=tabunselected a href=%=request.getContextPath()%/changePage.do?pageName =%=topMenuItem.getMenuItemName()% img src=%=commonImagePath%/page_name_right_unselected.gif border=0 /a /td % } } % /tr /table I realise that this is not best practice and I should be using the tag-libs but I'm struggling to make the tag-libs work, I'm also confused about whether this tile needs to be inside a form as I am not actually submitting anything (as in a Login page), however I do need to pass a pageName parameter into the request. The above example does work (sort of) however I am unable to extract the pageName parameter in my action class as it keeps returning null I would really appreciate some pointers as I thought I had struts figured but I now realise I've gone wrong somewhere along the line Regards Joanne Corless CSC Computer Sciences Limited ( Office +44 (0)1772 318025 ( Mobile +44 (0)7767 656588 * email [EMAIL PROTECTED] Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN CSC Computer Sciences Limited: Registered in England, No. 963578. Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire, GU11 1PZ. This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
actions best practice question
I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: actions best practice question
According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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]
RE: actions best practice question
Nico, I agree with that, and that is basically how I did. But I was wondering for the first time the action is called, basically just for displaying the page letting the user type in the fields values and click submit, what action do you use, if any? Cause, it's only the next time the action is called that the action is going to do real action. Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:24 PM To: Struts Users Mailing List Subject: Re: actions best practice question According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: actions best practice question
I use to set a specialized action-mapping for such init request, that is a simple forward (no Action class needed) /newUser/init.do = forward to newUser.jsp /newUser/register.do = RegiterUserAction = welcome.jsp^ if needed, forward to newUser.jsp can be easily changed by a full Action class (to init a form-bean with some default values for example) Nico. Nico, I agree with that, and that is basically how I did. But I was wondering for the first time the action is called, basically just for displaying the page letting the user type in the fields values and click submit, what action do you use, if any? Cause, it's only the next time the action is called that the action is going to do real action. Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:24 PM To: Struts Users Mailing List Subject: Re: actions best practice question According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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] - 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]
RE: actions best practice question
Nico, thanks a lot for the prompt answers. Do you use for that the org.apache.struts.actions.ForwardAction ? Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:48 PM To: Struts Users Mailing List Subject: Re: actions best practice question I use to set a specialized action-mapping for such init request, that is a simple forward (no Action class needed) /newUser/init.do = forward to newUser.jsp /newUser/register.do = RegiterUserAction = welcome.jsp^ if needed, forward to newUser.jsp can be easily changed by a full Action class (to init a form-bean with some default values for example) Nico. Nico, I agree with that, and that is basically how I did. But I was wondering for the first time the action is called, basically just for displaying the page letting the user type in the fields values and click submit, what action do you use, if any? Cause, it's only the next time the action is called that the action is going to do real action. Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:24 PM To: Struts Users Mailing List Subject: Re: actions best practice question According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: actions best practice question
I use a Forward action-mapping : action path=/newUser/init forward=/newUser.jsp / You can use ForwardAction instead : action path=/newUser/init type=org.apache.struts.actions.ForwardAction parameter=/newUser.jsp/ I think ForwardAction is prefered when you want this request to use a formbean and have validation. Nico. Nico, thanks a lot for the prompt answers. Do you use for that the org.apache.struts.actions.ForwardAction ? Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:48 PM To: Struts Users Mailing List Subject: Re: actions best practice question I use to set a specialized action-mapping for such init request, that is a simple forward (no Action class needed) /newUser/init.do = forward to newUser.jsp /newUser/register.do = RegiterUserAction = welcome.jsp^ if needed, forward to newUser.jsp can be easily changed by a full Action class (to init a form-bean with some default values for example) Nico. Nico, I agree with that, and that is basically how I did. But I was wondering for the first time the action is called, basically just for displaying the page letting the user type in the fields values and click submit, what action do you use, if any? Cause, it's only the next time the action is called that the action is going to do real action. Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:24 PM To: Struts Users Mailing List Subject: Re: actions best practice question According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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] - 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] - 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]
RE: actions best practice question
Thanks again Nico. -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 3:06 PM To: Struts Users Mailing List Subject: Re: actions best practice question I use a Forward action-mapping : action path=/newUser/init forward=/newUser.jsp / You can use ForwardAction instead : action path=/newUser/init type=org.apache.struts.actions.ForwardAction parameter=/newUser.jsp/ I think ForwardAction is prefered when you want this request to use a formbean and have validation. Nico. Nico, thanks a lot for the prompt answers. Do you use for that the org.apache.struts.actions.ForwardAction ? Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:48 PM To: Struts Users Mailing List Subject: Re: actions best practice question I use to set a specialized action-mapping for such init request, that is a simple forward (no Action class needed) /newUser/init.do = forward to newUser.jsp /newUser/register.do = RegiterUserAction = welcome.jsp^ if needed, forward to newUser.jsp can be easily changed by a full Action class (to init a form-bean with some default values for example) Nico. Nico, I agree with that, and that is basically how I did. But I was wondering for the first time the action is called, basically just for displaying the page letting the user type in the fields values and click submit, what action do you use, if any? Cause, it's only the next time the action is called that the action is going to do real action. Erez -Original Message- From: Nicolas De Loof [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 2:24 PM To: Struts Users Mailing List Subject: Re: actions best practice question According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing, and you can add some logic if needed. Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction). Nico. I have a login page with a link with forgot password? for users to retrieve the passwords to their email account in case they forgot it. It's pretty trivial but still using struts what is the best practice? Should the link inside the login page point to the ForgotPassword.jsp or to a ForgotPassword.do action? Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? Any comment would be greatly appreciated here, Thanks, Erez - 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] - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: actions best practice question
Currently I used a ForgotPassword.do, and in the action I check if there's an 'action' parameter with the value of 'send'. If the 'action' parameter does not exist then I locally forward to the ForgotPassword.jsp using struts-config.xml local forwards configuration. If it does exist and equals to 'send' then I perform the actual operation of going to the EJB layer and do what is necessary to do. Is this the way to do it, or am I missing the point here? You may consider utilizing the input forward. You can set the input attribute of the Action element to be forgotpassword.jsp, then in the Action, when the action parameter does not exist, just do: return mapping.getInputForward(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Newbie Design best practice question
If I were to have a STRUTS enabled application where I had user types of restricted_users, full_access_users, and admins and for the most part the content of the screens the different user types get to see are the same, except for maybe Id like there to be a few extra bits of functionality on the full_access_users and admin screens that doesn't get shown on the restricted_users screen, then what's the best way to go about this? It will probably also be that each user type will require some Action objects not used by the other user types. Should I attempt to use one set of JSPs for all the different types of users and put logic inside each of the JSPs that says something like 'if the user is of type full_access_users then shown these extra few buttons', or should I give each type of user their own set of JSPs? I am tempted to try and use one set of JSPs for all user types so that I don't have to worry about maintenance of three sets of almost identical JSP files. On the other hand I feel I may be asking for security trouble by trying to have each JSP check for the user's user type - I also have a notion that checking user types is something that I should be doing elsewhere. If I do use separate JSPs for each user type, would it make sense to use the STRUTS sub-application mechanism to separate them out? Thanks for your thoughts, - Jim -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT] Newbie Design best practice question
You might consider writing custom tags of the form custom:fulluser functionality for full user /custom:fulluser etc. This would keep the jsp simple but allow you to localize the functionality. Edgar -Original Message- From: Piper, James D CECOM SEC EPS [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 2:05 PM To: [EMAIL PROTECTED] Subject: [OT] Newbie Design best practice question If I were to have a STRUTS enabled application where I had user types of restricted_users, full_access_users, and admins and for the most part the content of the screens the different user types get to see are the same, except for maybe Id like there to be a few extra bits of functionality on the full_access_users and admin screens that doesn't get shown on the restricted_users screen, then what's the best way to go about this? It will probably also be that each user type will require some Action objects not used by the other user types. Should I attempt to use one set of JSPs for all the different types of users and put logic inside each of the JSPs that says something like 'if the user is of type full_access_users then shown these extra few buttons', or should I give each type of user their own set of JSPs? I am tempted to try and use one set of JSPs for all user types so that I don't have to worry about maintenance of three sets of almost identical JSP files. On the other hand I feel I may be asking for security trouble by trying to have each JSP check for the user's user type - I also have a notion that checking user types is something that I should be doing elsewhere. If I do use separate JSPs for each user type, would it make sense to use the STRUTS sub-application mechanism to separate them out? Thanks for your thoughts, - Jim -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [OT] Newbie Design best practice question
I would use 1 jsp for all groups with a custom tag to check if the user is in a given role: yourtags:checkIsInRole role=admin admin content here /yourtags:checkIsInRole Dave From: Piper, James D CECOM SEC EPS [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [OT] Newbie Design best practice question Date: Tue, 17 Sep 2002 14:05:29 -0400 If I were to have a STRUTS enabled application where I had user types of restricted_users, full_access_users, and admins and for the most part the content of the screens the different user types get to see are the same, except for maybe Id like there to be a few extra bits of functionality on the full_access_users and admin screens that doesn't get shown on the restricted_users screen, then what's the best way to go about this? It will probably also be that each user type will require some Action objects not used by the other user types. Should I attempt to use one set of JSPs for all the different types of users and put logic inside each of the JSPs that says something like 'if the user is of type full_access_users then shown these extra few buttons', or should I give each type of user their own set of JSPs? I am tempted to try and use one set of JSPs for all user types so that I don't have to worry about maintenance of three sets of almost identical JSP files. On the other hand I feel I may be asking for security trouble by trying to have each JSP check for the user's user type - I also have a notion that checking user types is something that I should be doing elsewhere. If I do use separate JSPs for each user type, would it make sense to use the STRUTS sub-application mechanism to separate them out? Thanks for your thoughts, - Jim -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT] Newbie Design best practice question
We just went through similar agony with four levels of users. We ended up with two sets of JSP pages. We ended up doing a second set for one of the groups because there was just so much of a difference and it would be helpful to have a different layout. Of course we are still working on it so I cant say it all worked out for us :) -Original Message- From: James.Piper [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 2:05 PM To: struts-user Subject: [OT] Newbie Design best practice question If I were to have a STRUTS enabled application where I had user types of restricted_users, full_access_users, and admins and for the most part the content of the screens the different user types get to see are the same, except for maybe Id like there to be a few extra bits of functionality on the full_access_users and admin screens that doesn't get shown on the restricted_users screen, then what's the best way to go about this? It will probably also be that each user type will require some Action objects not used by the other user types. Should I attempt to use one set of JSPs for all the different types of users and put logic inside each of the JSPs that says something like 'if the user is of type full_access_users then shown these extra few buttons', or should I give each type of user their own set of JSPs? I am tempted to try and use one set of JSPs for all user types so that I don't have to worry about maintenance of three sets of almost identical JSP files. On the other hand I feel I may be asking for security trouble by trying to have each JSP check for the user's user type - I also have a notion that checking user types is something that I should be doing elsewhere. If I do use separate JSPs for each user type, would it make sense to use the STRUTS sub-application mechanism to separate them out? Thanks for your thoughts, - Jim -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [OT] Newbie Design best practice question
Tiles can also help you separate JSPs by role--all you need to do is provide your own definition factory. In my current app, I created a definition factory to take the user's role into account. Then in my struts-config, I just forward to, say, template.home and Tiles does all the hard work of deciding which definition should be used. You can still have common elements, too (login, logout, headers, etc). That scheme helped us keep the JSPs a little cleaner than they would be otherwise (with giant blobs of foo:isRole name=admin.../foo:isRole all over the place) and also helped with organization and separation (so different teams could more easily focus on different roles). chris -Original Message- From: Piper, James D CECOM SEC EPS [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 1:05 PM To: [EMAIL PROTECTED] Subject: [OT] Newbie Design best practice question If I were to have a STRUTS enabled application where I had user types of restricted_users, full_access_users, and admins and for the most part the content of the screens the different user types get to see are the same, except for maybe Id like there to be a few extra bits of functionality on the full_access_users and admin screens that doesn't get shown on the restricted_users screen, then what's the best way to go about this? It will probably also be that each user type will require some Action objects not used by the other user types. Should I attempt to use one set of JSPs for all the different types of users and put logic inside each of the JSPs that says something like 'if the user is of type full_access_users then shown these extra few buttons', or should I give each type of user their own set of JSPs? I am tempted to try and use one set of JSPs for all user types so that I don't have to worry about maintenance of three sets of almost identical JSP files. On the other hand I feel I may be asking for security trouble by trying to have each JSP check for the user's user type - I also have a notion that checking user types is something that I should be doing elsewhere. If I do use separate JSPs for each user type, would it make sense to use the STRUTS sub-application mechanism to separate them out? Thanks for your thoughts, - Jim -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
best practice question
I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: best practice question
Subject: Re: best practice question From: Vic C [EMAIL PROTECTED] === No need to optimize, just do it as a formbean with c:for each or logic: iterate ...or html:options. v. Bill Blackmon wrote: I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: best practice question
Assuming these are application-level, read-only values, I would think you would want to load them at start and make them in application scope - yes. By doing so, not only do you not have to hit the database again, but you just reduced your over-all memory footprint too (since you don't have to mess around with loading them into a session/request). Be careful about what you put there and how you manage it though ;-) If these are values that change periodically, it may be easiest to just take the db hit. If they are fairly stable (ie. don't change a lot) then putting them into the application scope would seem to me a very good way to go about it. Hopefully someone else will have additional input ;-) Regards, Eddie Bill Blackmon wrote: I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: best practice question
Thanks. I'll try that. I guess I'd just create an instance of the form bean class at the entry to the app with the request passed in and create the form bean in application or session scope? The formbean would be declared in the struts.xml file with session or application scope? I'm just thinking out loud. I don't want the form bean to be attached to any action if possible. I'm new to this so bear with me! Thanks, Bill - Original Message - From: Struts Newsgroup @[EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:40 AM Subject: Re: best practice question Subject: Re: best practice question From: Vic C [EMAIL PROTECTED] === No need to optimize, just do it as a formbean with c:for each or logic: iterate ...or html:options. v. Bill Blackmon wrote: I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: best practice question
You don't want it in the session if it's very big! There's no reason to load this data repeatedly (for each user!) if it is non-volatile! Load it on startup as I mentioned in my other post and merely reference it. If it is volatile you'll have to devise some strategy for updating it. Assuming that, when it is updated, you only have one writer (we know there are many possible readers), you shouldn't have to serialize any access to it. That would be the most straight-forward implementation (you wouldn't really need anything to manage updates). If (parts of) it may be updated by multiple threads, you'll want to either serialize updates to those pieces or take the db hit to retrieve it when you need it. HTH, Eddie Bill Blackmon wrote: Thanks. I'll try that. I guess I'd just create an instance of the form bean class at the entry to the app with the request passed in and create the form bean in application or session scope? The formbean would be declared in the struts.xml file with session or application scope? I'm just thinking out loud. I don't want the form bean to be attached to any action if possible. I'm new to this so bear with me! Thanks, Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: best practice question
You don't want a form bean for this data, because you're not associating it with a specific form, and because a form bean is not instantiated until it's needed by the html:form tag or an associated action, neither of which will happen in your scenario. Your original idea is the right one. Load the data from the database at startup time, storing it in one or more regular JavaBeans, as appropriate. Then, assuming the data is application-wide, you can put the JavaBean(s) in application scope, or create a singleton to hold them. The easiest place to do this work is in a Plugin, if you're using Struts 1.1-b1 or a nightly build. It's an extremely simple interface, and a snap to use. -- Martin Cooper -Original Message- From: Bill Blackmon [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 8:09 AM To: Struts Users Mailing List Subject: Re: best practice question Thanks. I'll try that. I guess I'd just create an instance of the form bean class at the entry to the app with the request passed in and create the form bean in application or session scope? The formbean would be declared in the struts.xml file with session or application scope? I'm just thinking out loud. I don't want the form bean to be attached to any action if possible. I'm new to this so bear with me! Thanks, Bill - Original Message - From: Struts Newsgroup @[EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:40 AM Subject: Re: best practice question Subject: Re: best practice question From: Vic C [EMAIL PROTECTED] === No need to optimize, just do it as a formbean with c:for each or logic: iterate ...or html:options. v. Bill Blackmon wrote: I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: best practice question
Thanks - that's what I wanted to use and it's the way I've handled situations like this in other types of apps. The formbeans aren't stable since they're always being reset at intervals I can't quite understand the reasoning behind at this point in my development. The collections will never be updated, at least not while they're in memory. I'll look into the Plug-In option and see what it offers. Thanks, Bill - Original Message - From: Martin Cooper [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Monday, July 29, 2002 2:33 PM Subject: RE: best practice question You don't want a form bean for this data, because you're not associating it with a specific form, and because a form bean is not instantiated until it's needed by the html:form tag or an associated action, neither of which will happen in your scenario. Your original idea is the right one. Load the data from the database at startup time, storing it in one or more regular JavaBeans, as appropriate. Then, assuming the data is application-wide, you can put the JavaBean(s) in application scope, or create a singleton to hold them. The easiest place to do this work is in a Plugin, if you're using Struts 1.1-b1 or a nightly build. It's an extremely simple interface, and a snap to use. -- Martin Cooper -Original Message- From: Bill Blackmon [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 8:09 AM To: Struts Users Mailing List Subject: Re: best practice question Thanks. I'll try that. I guess I'd just create an instance of the form bean class at the entry to the app with the request passed in and create the form bean in application or session scope? The formbean would be declared in the struts.xml file with session or application scope? I'm just thinking out loud. I don't want the form bean to be attached to any action if possible. I'm new to this so bear with me! Thanks, Bill - Original Message - From: Struts Newsgroup @[EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 29, 2002 10:40 AM Subject: Re: best practice question Subject: Re: best practice question From: Vic C [EMAIL PROTECTED] === No need to optimize, just do it as a formbean with c:for each or logic: iterate ...or html:options. v. Bill Blackmon wrote: I have several iterators filled from db calls that will be used across the app for select boxes, lists of checkboxes, radio button etc.. In the context of Struts, would it be best to load these items as application level items at startup and define them in the struts-config.xml file with a reference to the class that does the loading? Any opinions are greatly appreciated. Bill -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question/Conceptual Problem
There's an option for using a Map if you need more than one parameter. Struts Newsgroup (@Basebeans.com) wrote: Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Mark et al, Thank you all for your help, I've gotten it to work, and I understand the concept now. My next hurdle is using the bean data in html:link tags. I've found that I can use the paramId, paramName and paramProperty tags to add a parameter to the html:link, but what if I want to add 2 params? It seems kind of silly to hardcode the ability to add one parameter. Am I missing something? Kenny Smith -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question/Conceptual Problem
can you really use bean:define before the logic:iterate tag? I did something similar (i forget if i used bean:define or jsp:useBean) and I got errors complaining about the id variable already existing or that it had already been declared. i may have been doing something wrong, but it didn't work for me. Keith Kamholz Moog East Aurora, NY (716) 687-7282 [EMAIL PROTECTED] -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 4:40 PM To: 'Struts Users Mailing List' Subject: RE: Best Practice Question/Conceptual Problem It gets it from a JavaBean, List or Map either already in some reachable scope or defined in your JSP. For example, if I've defined a list of states in an action class like: List statesList = new ArrayList( State.getStates()); where State is a command object or stateless session bean querying the database to retrieve a list of states, and I stick them into application scope (so everyone can use it): ServletContext servletContext = this.servlet.getServletContext(); servletContext.setAttribute( listStates, listStates); I can iterate through this list on a JSP and display the names like: table logic:iterate name=listStates // the List property=state // a state object id=states// arbitrary page-scope name scope=application type=com.whatever.State trtd bean:write name=states property=name / /td/tr /logic:iterate /table or perhaps I need a data object specific to the user on the JSP: bean:define name=customer property=data type=com.whatever.Customer id=orders scope=session / where customer is an Order object specific to this customer's ID (retrieved from the database when the user passes his ID through a form), so I can display the pending orders this customer has placed: table logic:iterate name=orders property=customerOrders id=order type=com.whatever.CustomerOrder trtd bean:write name=order property=pending / /td/tr /logic:iterate /table There are tons of examples in the archive. Mark -Original Message- From: Struts Newsgroup [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 4:10 PM Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Keith, But how does the logic:iterate tag know where to get the information from? That's the part that is really baffling me. I don't understand how it's getting the information, so I'm not sure how to apply it to other applications, etc. Could you (or anyone) please explain how it knows? Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Best Practice Question/Conceptual Problem
Subject: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hello, I'm trying to write my first struts application, and I'm looking for guidance on how to accomplish a certain task. I've read through the Struts Userguide and I've been going through the struts-example application, but I'm not exactly sure what concept I'm missing that is keeping me from wrapping my head around the problem. I have a list of markets in a database table. I have a Market bean that can be instantiated to represent a row in the table, and it has static methods for finding markets by id, creating markets, etc. I would like my user to be able to click a List Active Markets link and have it take them to a page where it lists the markets. Seems simple enough, but I can't figure out how to make the data available to my JSP page. I assume I should use a logic:iterate tag to display data for each of the markets, but I just don't understand how I make the data available to the JSP or logic:iterate tag. I've been reading and reading, and I can't figure it out, there seems to be some piece missing. Can anyone help me? This seems like a fairly basic/common action, so is there anyone out there that has suggestions for the best practice solution? Thanks, Kenny Smith JournalScape.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question/Conceptual Problem
Hi When your users request the list, the request goes to an action... The action calls the appropriate things to get the data... It then stuffs the information into the session and forwards the request to a JSP page The JSP page pulls the data out, builds the page and sends it back to the user... Does that help? -Original Message- From: struts [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 12:25 PM To: struts-user Subject: Best Practice Question/Conceptual Problem Subject: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hello, I'm trying to write my first struts application, and I'm looking for guidance on how to accomplish a certain task. I've read through the Struts Userguide and I've been going through the struts-example application, but I'm not exactly sure what concept I'm missing that is keeping me from wrapping my head around the problem. I have a list of markets in a database table. I have a Market bean that can be instantiated to represent a row in the table, and it has static methods for finding markets by id, creating markets, etc. I would like my user to be able to click a List Active Markets link and have it take them to a page where it lists the markets. Seems simple enough, but I can't figure out how to make the data available to my JSP page. I assume I should use a logic:iterate tag to display data for each of the markets, but I just don't understand how I make the data available to the JSP or logic:iterate tag. I've been reading and reading, and I can't figure it out, there seems to be some piece missing. Can anyone help me? This seems like a fairly basic/common action, so is there anyone out there that has suggestions for the best practice solution? Thanks, Kenny Smith JournalScape.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question/Conceptual Problem
Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === It then stuffs the information into the session and forwards the request to a JSP page The JSP page pulls the data out, builds the page and sends it back to the user... Does that help? Somewhat, yes. I understand how to get the information, but putting it in the session and retreiving it is where I sort of fall down. I understand the syntax of putting something in the session (although I haven't been able to find where the Constants class is, that is used in every example).. but something like: Market[] markets = Market.findByActive( true ) ; HttpSession session = request.getSession() ; session.put( markets , markets ) ; Is that correct? but how do I get it out of the session to use with the logic:iterate tag? Thanks for the reply, Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question/Conceptual Problem
Use something like this: logic:iterate id=temp name=markets type=Market Do this on each iteration /logic:iterate The tag should take care of everything for you. I forget if you have to specify scope=session in the logic:iterate, but if you have problems try adding it. ~ Keith -Original Message- From: Struts Newsgroup [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 2:25 PM To: [EMAIL PROTECTED] Subject: Re: Best Practice Question/Conceptual Problem Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === It then stuffs the information into the session and forwards the request to a JSP page The JSP page pulls the data out, builds the page and sends it back to the user... Does that help? Somewhat, yes. I understand how to get the information, but putting it in the session and retreiving it is where I sort of fall down. I understand the syntax of putting something in the session (although I haven't been able to find where the Constants class is, that is used in every example).. but something like: Market[] markets = Market.findByActive( true ) ; HttpSession session = request.getSession() ; session.put( markets , markets ) ; Is that correct? but how do I get it out of the session to use with the logic:iterate tag? Thanks for the reply, Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question/Conceptual Problem
Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Keith, But how does the logic:iterate tag know where to get the information from? That's the part that is really baffling me. I don't understand how it's getting the information, so I'm not sure how to apply it to other applications, etc. Could you (or anyone) please explain how it knows? Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question/Conceptual Problem
Your best bet is to take a look at some source code for the taglibs, it can clear up a few things for you. HTH! James Mitchell Software Engineer\Struts Evangelist Struts-Atlanta, the Open Minded Developer Network http://struts-atlanta.open-tools.org -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 4:10 PM To: [EMAIL PROTECTED] Subject: Re: Best Practice Question/Conceptual Problem Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Keith, But how does the logic:iterate tag know where to get the information from? That's the part that is really baffling me. I don't understand how it's getting the information, so I'm not sure how to apply it to other applications, etc. Could you (or anyone) please explain how it knows? Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question/Conceptual Problem
The name parameter you pass to the iterate tag matches the name of the attribute in (page,request,session,application) scope. In other words, the context and the tags use the same protocol for the property names. The other parameter to iterate, id, tells the tag what name to use when it exposes each entry in the collection. The tag looks in the page context first, then request, session, and application. (Unless you specify a scope.) Struts Newsgroup (@Basebeans.com) wrote: Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Keith, But how does the logic:iterate tag know where to get the information from? That's the part that is really baffling me. I don't understand how it's getting the information, so I'm not sure how to apply it to other applications, etc. Could you (or anyone) please explain how it knows? Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question/Conceptual Problem
It gets it from a JavaBean, List or Map either already in some reachable scope or defined in your JSP. For example, if I've defined a list of states in an action class like: List statesList = new ArrayList( State.getStates()); where State is a command object or stateless session bean querying the database to retrieve a list of states, and I stick them into application scope (so everyone can use it): ServletContext servletContext = this.servlet.getServletContext(); servletContext.setAttribute( listStates, listStates); I can iterate through this list on a JSP and display the names like: table logic:iterate name=listStates // the List property=state // a state object id=states// arbitrary page-scope name scope=application type=com.whatever.State trtd bean:write name=states property=name / /td/tr /logic:iterate /table or perhaps I need a data object specific to the user on the JSP: bean:define name=customer property=data type=com.whatever.Customer id=orders scope=session / where customer is an Order object specific to this customer's ID (retrieved from the database when the user passes his ID through a form), so I can display the pending orders this customer has placed: table logic:iterate name=orders property=customerOrders id=order type=com.whatever.CustomerOrder trtd bean:write name=order property=pending / /td/tr /logic:iterate /table There are tons of examples in the archive. Mark -Original Message- From: Struts Newsgroup [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 4:10 PM Subject: Re: Best Practice Question/Conceptual Problem From: Kenny Smith [EMAIL PROTECTED] === Hi Keith, But how does the logic:iterate tag know where to get the information from? That's the part that is really baffling me. I don't understand how it's getting the information, so I'm not sure how to apply it to other applications, etc. Could you (or anyone) please explain how it knows? Kenny -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question.
Hi, I see three options: a) make the config-bean a singleton: easy to access from everywhere in the JVM b) put the config-bean into the servlet-context: makes it easy to access it within the webapp, but somehow you need access to request or servlet-context c) create a lookup-bean (JVM-singleton) and have this bean provide access to the config-bean: usefull if you have more than one bean. Eg. we use it to give our apps access to some helper-classes. Always the same mechanism to access whatever helper-class one needs... hope this helps Alexander -Original Message- From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 30. April 2002 19:51 To: Struts User List Subject: Best Practice Question. I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Best Practice Question.
I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question.
This is rather vague. Why does your logicBean need your configBean? Mark -Original Message- From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 30, 2002 1:51 PM I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question.
Depends. If the logic bean is a form bean, the action class should extract values from config bean and then call set methods on form bean, i.e. a clean separation between db beans and form beans. else, pass the config bean to logic bean. -GB -Original Message- From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 30, 2002 1:51 PM To: Struts User List Subject: Best Practice Question. I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question.
I have set up a mechanism similar to Tomcat's Realm at the app level. It is used to identify the database name(jndi),tables and columns that contain user and role information in the database. At the start of my app the database information is placed into an application scope bean using digester. Then whenever a secure url is requested I have a Filter class that routes to the security Action upon request of secure url then to a specified login form. When the login form is submitted a validation of the username and password needs to occur. This is the point at which I have a logic bean that validates against thte database. It does so by checking the specified database,tables and columns for user validation etc...(there is much more detail but I think this is sufficient to get the point). So, this explains why I have a config bean and a need to pass info to the logic bean. All I want to know is, is what I am doing proper form? Is it accepted practice to pass a bean to a bean? Also, please don't turn this into a discussion of Why not use container based security? As a note, I already do in a round-about way. :-) Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 30, 2002 12:03 PM To: 'Struts Users Mailing List' Subject: RE: Best Practice Question. This is rather vague. Why does your logicBean need your configBean? Mark -Original Message- From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 30, 2002 1:51 PM I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Best Practice Question.
Hello, Here's how I pass around Configuration properties in my Struts application. Certainly this isn't the best practise, but just an idea; I have created a Singleton class called 'PropertyRetriever' which is simillar to the Service Locator design pattern. It uses Digester to read configuration properties from a XML file. Here's what it looks like; public class PropertyRetriever { // Singleton's private instance private static PropertyRetriever me; private static Digester digester = null; private static AppRoot root = null; static { try { me = new PropertyRetriever(); } catch (Exception ex) { //throw new PropertyRetrieverException(); } } private PropertyRetriever() throws Exception { //private construtor to avoid instantiation getProperties(); } // Returns PropertyRetriever instance static public PropertyRetriever getInstance() { return me; } private void getProperties() throws Exception { // Configure digester digester = new Digester(); etc etc. Now from my Action Classes in Struts, I can get any property as follows; PropertyRetriever propertyRetriever = PropertyRetriever.getInstance(); String appName = propertyRetriever.getAppRoot().getAppName(); I am sure there are pros cons of this approach. HTH! -- Original Message -- Reply-To: Struts Users Mailing List [EMAIL PROTECTED] From: Phase Web and Multimedia [EMAIL PROTECTED] To: Struts User List [EMAIL PROTECTED] Subject: Best Practice Question. Date: Tue, 30 Apr 2002 11:50:30 -0600 I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Ajay Chitre Diligent Team, Inc. (Where Diligent People Work as a Team) http://www.DiligentTeam.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question.
On Tue, 30 Apr 2002, Phase Web and Multimedia wrote: Date: Tue, 30 Apr 2002 11:50:30 -0600 From: Phase Web and Multimedia [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts User List [EMAIL PROTECTED] Subject: Best Practice Question. I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. You'll need to pass a reference to the config bean as a parameter to a logic bean method. You could instead pass a reference to the servlet context (so that it could pull out the config bean attribute), but that ties you more tightly to running only in a web application -- presumably, your config bean doesn't have any javax.servlet.* imports in it, so it could be reused elsewhere. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Best Practice Question.
The goal of keeping business logic out of action classes (IMHO) is to increase the reusability of the logic. Based on this, I would say it depends on how you use your value / logic / config beans on your non-web-based applications (if any). Or, how you would use them if/when you went to build other (non-web-based) applications. Have foresight. Think of how you can make the most out of what you are going to write. Have as your end goal reusability. Build everything on that precept. No, you can't reuse everything you write, but the goal is to maximize code reuse. HTH, Eddie - Original Message - From: Phase Web and Multimedia [EMAIL PROTECTED] To: Struts User List [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 12:50 PM Subject: Best Practice Question. I have a bean that is created when my app starts and it contains some database table conifguration info (I'll call it my config bean). Later on in an Action class another bean, that I'll call my logic bean, needs to access the values of the config bean. Would it be proper to use the Action class to pass the config bean to the logic bean and let the logic bean extract the values or should I extract all the values from the config bean within the Action class and pass the config info in a different manner. Thanks, Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]