RE: Templates Images

2001-08-15 Thread Aaron Ravenberg

Using template:put tag show below is trying to put an image file as
include into the JSP.template, then asking the JSP.template to compile.
What you really want to display is the String '/images/example.gif'.  So you
have to specify a my.JSP that contained the text '/images/example.gif',
therefore you would need to use a html img src=template:get  or have
the my.JSP file contain the html:img tag.

If you only have a few images that can be displayed and depending on what
you use to determine to display them, wrapping the img tags in
logic:present tags might be a solution.

-Aaron

-Original Message-
From: James Maggs [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 15, 2001 10:00 AM
To: [EMAIL PROTECTED]
Subject: Templates  Images


Hi There,

I'm working on a Struts powered site right now and have come up against a
bit of a problem. I'm using the templating tags to give my pages a uniform
look and feel. However I'd like to be able to insert images into my
template. I figured the best way would be as follows:

template:insert template='/template.jsp'
  template:put name='image' content='/images/example.gif' direct='true' /
/template:insert

But this begs the question, how do you insert the content into the src
attribute of the image tag? I suppose I could put the whole image tag into
the template but I'd rather avoid embedding content in the above code.

Can anyone suggest a best way forward?

Many thanks,

-James




RE: Struts Design Question

2001-08-08 Thread Aaron Ravenberg

Yes you can do the add/edit all on the same form.  If have a database
generated code or key you can put that in a hidden field.  When in the
action examine the form or request obj to see if that key is there, if it is
you have a modify, if not add the record.

Have you page that lists the songs pass a the code/key as a parameter to the
SongForm.jsp. Then you can use the jsp:useBean as follows:

jsp:useBean id=SongForm class=com.mypackage.SongForm scope=request 
 jsp:setProperty name=SongForm property=songKey param=songKey /
/jsp:useBean

Then to pre populate the form you can make a DataBase call in your form
setSongKey() method and use the result to set the other values in the form.

For a delete you can have a second form on the same page (with its own
submit button) that has the songKey set into the SongDeleteForm and the
submit is mapped to a DeleteAction that just uses the key to delete the
record.

I am new at the struts stuff myself, so these may not be the best ways to
accomplish what you are trying to do, but I know it works.  So anyone else
please feel free to critique.

Aaron


-Original Message-
From: Shriver, Ryan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 08, 2001 9:30 AM
To: '[EMAIL PROTECTED]'
Subject: Struts Design Question


Hello all,
I downloaded Struts last week and have enjoyed playing with it. I've come
upon a design problem and I was hoping some folks on this list could help
solve it. I've had no luck finding an answer in the mail archives.

I want to maintain a list of songs. Through a web interface, I want to add a
new song, edit information about an existing song (composer, artist, etc)
and also delete a song. Under the covers this will do some sort of database
insert, update and delete, respectively.

The forms for adding a new song and editing an existing song are practically
identical. They contain the same field names with the difference being edit
pre-populates the fields with the existing values of a song whereas the
fields are blank for add. Question #1: Can one ActionForm suffice for both
add and edit form pages? My gut says yes, but I want to make sure.

Actions. In the simplest scenario, I could create separate actions for all
operations. I'd have AddSongAction, EditSongAction and DeleteSongAction
classes each with their own logic in perform(). This would work, but there's
something that bothers me about having three different classes performing
operations on one entity. It seems like overkill.

DispatchActions. I saw the post about using DispatchAction to have multiple
methods in a single Action class. I really like this approach, as I could
have insert, update and delete methods in my Action class. However, the
input= attribute in the action mapping definition (in struts-config.xml)
is shared for all of them. So if I have separate addsong.jsp and
editsong.jsp form pages sharing the same Action, and a validation error
occurs, Struts can only return to one (whatever input= is). So this won't
work.

Question #2: Is there a happy medium between these two approaches?

One idea that I haven't worked through is using one songform.jsp page for
add/edit/delete. Calling songform.jsp?method=add would produce a blank page
for entering a new song. Songform.jsp?method=editid=1234 would populate the
form with values from a song whose id = 1234. From here one could edit or
delete the selected song. In Struts I'd use the DispatchAction to pass all
add/edit/delete requests to one Action class. Because all were using the
same form, the input= attribute problem above would be avoided.

Question #3: Will this approach work? Can anyone offer a better solution for
this problem?

Thanks for the feedback.

-ryan




Action Errors

2001-08-06 Thread Aaron Ravenberg

Hello all,

I did not find an example of the use of this ActionError method.  If someone
could point me to a good example or reply with one I would appreciate it.  I
just wasn't clear how the Object part of the method works.  What object(s)
can you use?  How are they structured so they can replace values.  How are
those values to be replaced identified?

Method:

public ActionError(java.lang.String key,
   java.lang.Object value0)

Construct an action error with the specified replacement values.

Parameters:
key - Message key for this error message
value0 - First replacement value

Thank you,

Aaron




RE: Confirmation page

2001-08-03 Thread Aaron Ravenberg

Sorry, every one just noticed the follow up on this thread, didn't see it in
th e 112 msgs I got this morning :)

Aaron Ravenberg

-Original Message-
From: Aaron Ravenberg [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 03, 2001 9:01 AM
To: [EMAIL PROTECTED]
Subject: RE: Confirmation page


If you can use JavaScript it would be the most simple solution. It seems
that writing a confirm form and action to accommodate every page you want
this functionality in might be a little much when you compare it to a few
lines of JavaScript.

As mentioned in another reply you can use the bean:message with in the
JavaScript code.

Aaron Ravenberg


-Original Message-
From: Liu, Xin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 6:16 PM
To: [EMAIL PROTECTED]
Subject: RE: Confirmation page


Hi,
I think you misunderstood the scope of request. I think you have the
following workflow diagram:
first_page(browser)--Server_process1--Confirmation_page(browser)--Server_
process2

I think your Java code is running during Server_process1, and it puts your
first_page's information into your bean, which is in the request scope.
After the control is transfered  to Confirmation_page. All information in
the request scope is destroyed. So when you come back to Server_process2, it
will tell you: Cannot find the form bean in the request scope.

You have several ways to keep the formBean information available in
Server_process2.
1. Make the FormBean's scope be Session.
2. Put the information of the formBean as hidden fields in
Confirmation_page.

Hope this will be helpful.

Xin


-Original Message-
From: Yuriy Zubarev [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 2:37 PM
To: [EMAIL PROTECTED]
Subject: Confirmation page


Hello everyone,

I have a form (in request scope) with submit and cancel
buttons and after pushing either of them I should display
a confirmation dialog (Are you sure?) and depending on user's
choice I have to perform the actual action 'submit' or 'cancel'
if user clicks 'yes' and have to return to the same page with
form if user clicks 'no'. The need of this confirmation routine
is questionable but this is not the point in this case, the point
is how to preserve everything you have in your request while
making this trip.

I tried to do this in my action which calls confirmation
page and confirmation page itself (as scriplet):

java.util.Enumeration enum = request.getAttributeNames();

while (enum.hasMoreElements()) {
  String atName = (String) enum.nextElement();
  request.setAttribute(atName, request.getAttribute(atName));
}

But this didn't help because if I click 'no' button (a link
technically speaking, which leads me to the jsp page with form)
I get an error 'No bean found under attribute key userForm'

I would appreciate any suggestion related to this problem.

Thank you for your time.

Best of luck,
Yuriy Zubarev



__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/




logic:iterate and html:option

2001-07-26 Thread Aaron Ravenberg



Hi all,

I want to use the iterate tag to develop the html:option set for a
html:select, is there a way to specify the html:option value=???  with
the bean:write name=list property=value / tag that can be used in the
iteration of my webVendorTreeMap?

  html:select property=webVendorKey name=webVendorKey 
   // iterate TreeMap to develop the options for the select
   logic:iterate id=list property=webVendorTreeMap name=FormBean
html:option value=???
  // use the key value from the TreeMap to set text display
  bean:write name=list property=key /
/html:option
   /logic:iterate
  /html:select

Thank you,

Aaron




RE: logic:iterate and html:option

2001-07-26 Thread Aaron Ravenberg

I firgured out thx, was looking at the wrong tag description :)

- Aaron

-Original Message-
From: Aaron Ravenberg [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 26, 2001 9:58 AM
To: [EMAIL PROTECTED]
Subject: logic:iterate and html:option




Hi all,

I want to use the iterate tag to develop the html:option set for a
html:select, is there a way to specify the html:option value=???  with
the bean:write name=list property=value / tag that can be used in the
iteration of my webVendorTreeMap?

  html:select property=webVendorKey name=webVendorKey 
   // iterate TreeMap to develop the options for the select
   logic:iterate id=list property=webVendorTreeMap name=FormBean
html:option value=???
  // use the key value from the TreeMap to set text display
  bean:write name=list property=key /
/html:option
   /logic:iterate
  /html:select

Thank you,

Aaron




RE: html:tags and templates

2001-07-19 Thread Aaron Ravenberg

Thank you for your reply,

I actually was able to figure out last night that it had to do with my
server enviroment.  When I ran the files on another machine they worked
*cheer*.

Thank you

Aaron

-Original Message-
From: Cedric Dumoulin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 19, 2001 4:43 AM
To: [EMAIL PROTECTED]
Subject: Re: html:tags and templates



  You certainly have an error in 'login.jsp' or 'myheader.jsp', caught by
the
get tag. Have you try to call these pages directly ? Do they work ?

  Cedric

Aaron Ravenberg wrote:

 Hi,

 My html:TAGS are not working with my template set up.  When I include
the
 html and bean taglib directive in my login.jsp it my server throws a
 javax.servlet.ServletException: runtime failure in custom tag 'get'.
When
 I move it to the template.jsp or index.jsp, the tags print out in the
source
 but do not do anything.  Any pointers would be appreciated.  Sample code
 included below.  I am using weblogic 5.1 sp 9

 Thank you,

 Aaron Ravenberg

 index.jsp

 template:insert template=/template.jsp 
  template:put name=header content=/myheader.jsp direct=false /
  template:put name=body content=/login.jsp direct=false /
 /template:insert

 template.jsp

 html
  body
   table
trtdtemplate:get name=header //td/tr
trtdtemplate:get name=body //td/tr
   /table
  /body
 /html

 login.jsp

 html:html
  html:form name=loginForm action=login.do 
   table
trtdhtml:text property=userid size=15/td/tr
trtdhtml:password property=password size=15/td/tr
  /html:form
 /html:html

 myHeader.jsp

 Just static html




html:tags and templates

2001-07-18 Thread Aaron Ravenberg

Hi,

My html:TAGS are not working with my template set up.  When I include the
html and bean taglib directive in my login.jsp it my server throws a
javax.servlet.ServletException: runtime failure in custom tag 'get'.  When
I move it to the template.jsp or index.jsp, the tags print out in the source
but do not do anything.  Any pointers would be appreciated.  Sample code
included below.  I am using weblogic 5.1 sp 9

Thank you,

Aaron Ravenberg


index.jsp

template:insert template=/template.jsp 
 template:put name=header content=/myheader.jsp direct=false /
 template:put name=body content=/login.jsp direct=false /
/template:insert


template.jsp

html
 body
  table
   trtdtemplate:get name=header //td/tr
   trtdtemplate:get name=body //td/tr
  /table
 /body
/html

login.jsp

html:html
 html:form name=loginForm action=login.do 
  table
   trtdhtml:text property=userid size=15/td/tr
   trtdhtml:password property=password size=15/td/tr
 /html:form
/html:html

myHeader.jsp

Just static html




Struts Deployment

2001-07-17 Thread Aaron Ravenberg

Hello all,

I have just started using struts and I was wondering what is the best way to
deploy struts for development, so I can avoid using a war file until it is
ready to deploy in test or production?  The documentation seems mostly
geared toward deployment as a war file and the ActionServlet seems to need
the action mapping described in the web.xml.

I am using weblogic 5.1 sp 9

Thank you,

Aaron Ravenberg