RE: XML include hack to split struts-config.xml

2001-09-10 Thread Daniel Toms

I've never gotten it to work either, but I would love to hear a solution
myself.

I know what is suppossed to happen, but I haven't seen anyone concretely
give
their example of doing it.

dan



 -Original Message-
 From: Renaud Waldura [mailto:[EMAIL PROTECTED]]
 Sent: Monday, September 10, 2001 4:08 PM
 To: [EMAIL PROTECTED]
 Subject: XML include hack to split struts-config.xml


 I found out about the XML include hack that can be used to split the
 struts-config.xml in more manageable portions:

 http://jakarta.apache.org:8080/jyve-faq/Turbine/screen/DisplayQues
 tionAnswer
 /action/SetAll/project_id/2/faq_id/16/topic_id/196/question_id/752

 It's been mentioned many times before on this list, but I'm
 having a hell of
 a time getting to work, especially with relative paths. Is anyone
 doing this
 in the context of WAR deployment?

 My current declaration is like this:

 !DOCTYPE struts-config PUBLIC
 -//Apache Software Foundation//DTD Struts Configuration 1.0//EN
 http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
 [
!ENTITY downloadClientActions SYSTEM
 file:./WEB-INF/config/struts/actions-downloadClient.xml
 ]
 

 But it chokes with a I/O error. Using an absolute path in the file: URI
 makes it work, but this is highly undesirable. I've tried every
 combination
 I could think of, no luck.

 Struts-config is fed to the ActionServlet with:

   init-param
param-nameconfig/param-name
param-value/WEB-INF/config/struts/struts-config.xml/param-value
   /init-param

 Any clues?

 --Renaud





anyway to flush the MessageResources?

2001-08-21 Thread Daniel Toms

Hi,


Is there any way to flush the message resources cache?

My requirement is to be able to dynamically edit labels
without bouncing the servlet container.  I have my own
MessageResources implementation that connects to our
own dictionary which is loaded from the db.  So the 
problem is that even though I have changed a value associated
with a key and it is persisted to the db, the new call
never gets made due to the caching in the method below.  I am using 
the struts 1.0 release.

Right now I am thinking the only solution is to subclass ActionServlet,
and then provide a public wrapper for the initApplication() method, so 
that I can call it from an action class, but I just want to make sure there
isn't an easier way, as I have been avoiding subclassing the ActionServlet
for a few months now ;)

thanks,

dan


   public String getMessage(Locale locale, String key, Object args[]) {

// Cache MessageFormat instances as they are accessed
if (locale == null)
locale = defaultLocale;
MessageFormat format = null;
String formatKey = messageKey(locale, key);
synchronized (formats) {
format = (MessageFormat) formats.get(formatKey);
if (format == null) {
String formatString = getMessage(locale, key);
if (formatString == null) {
if (returnNull)
return (null);
else
return (??? + formatKey + ???);
}
format = new MessageFormat(formatString);
formats.put(formatKey, format);
}

}
return (format.format(args));

}





splitting of struts config was RE: ActionServlet.addMapping() persistence

2001-08-08 Thread Daniel Toms

Craig, or anyone,

Has anyone actually gotten the below xml inclusion mechanism to
work using struts and tomcat 3.2.1?  I searched other
messages about this in the archives and none of the authors
were successful.  I always get a parse error like:

che/struts/resources/web-app_2_3.dtd'
Parse Fatal Error at line 5 column -1: Relative URI forms.xml; can not be
reso
lved without a document URI.
org.xml.sax.SAXParseException: Relative URI forms.xml; can not be resolved
wit
hout a document URI.

Our application is getting large and I would dearly like to use
this idea to split up the config file

thanks,

dan

 -Original Message-
 From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, August 08, 2001 12:41 PM
 To: [EMAIL PROTECTED]
 Subject: Re: ActionServlet.addMapping() persistence




 There's an XML trick that lets you do this without needing to modify
 Struts.  Consider that you've got a struts-config.xml file divided into
 three parts (form-beans.xml, global-forwards.xml, and
 action-mappings.xml) stored in the /WEB-INF directory.  They can be
 combined automatically by doing something like this in
 struts-config.xml:

   ?xml version=1.0?
   !DOCTYPE ...  [
 !ENTITY part1 SYSTEM form-beans.xml
 !ENTITY part2 SYSTEM global-forwards.xml
 !ENTITY part3 SYSTEM action-mappings.xml
   ]

   struts-config

 form-beans
   part1;
 /form-beans

 global-forwards
   part2;
 /global-forwards

 action-mappings
   part3;
 /action-mappings

   /struts-config

 Obviously, you can extend this concept to any reasonable separation of
 struts-config.xml into subordinate files.

  I suppose I could update struts-config.xml and then tell the
 ActionServlet
  to reread it in the Action I talked about in the first
 paragraph...I'd like
  to be able to seperate this out, if possible, to make the seperate
  components of my webapplication seperate.  The problem with
 putting this all
  into individual webapps is that I want the session to be passed
 from one
  part of the webapp to the next.
 

 The other approach would be to keep the individual pieces of
 struts-config.xml in separate files in your source repository, and use the
 Unix cat tool (or the DOS copy tool using plus signs) to concatenate
 the pieces together as you deploy the web app.

  Any thoughts?
  Thanks,
  Becky
 

 Craig





localization of numbers, etc.

2001-06-15 Thread Daniel Toms

I am wondering if the struts html:text tag supports the localization of
number formats? And if not, whether it even should?

thanks,

dan






how to restrict direct access to jsps(and have struts work)

2001-04-17 Thread Daniel Toms

Hello,

I'm using Struts and Tomcat 3.2.1.  Is it possible to set
things up so that jsps cannot be directly accessed at all,
but must always be referenced through an action?  I
had writen a checkLogon tag for inclusion in each
jsp when the above question occured to me.  I've looked
at web.xml descriptions etc., but I don't really want
to setup role based security, I just want any URL of
the type http://localhost:8080/CompEnterprise/jsp/ to get a 404,
yet still allow Struts to forward to them and work...this
would allow me to do logon validation within the actions and
not the jsps.  This would also solve the problem of someone
going to a jsp that depends on request data that is set by
the action.

thanks,

dan






can someone post an example of bean:message using parametric replacement

2001-04-13 Thread Daniel Toms

Hi,

Can someone post a concrete example of a bean:message ... tag
using parametric replacements and also post the corresponding lines
from the properties file.  I am having some difficulty understanding it.

thanks,

dan





RE: can someone post an example of bean:message using parametric replacement

2001-04-13 Thread Daniel Toms

thanks.  I'm trying to figure out how to setup correctly for
localizition, especially where you have cases like

Product Name

versus (excuse my spanish)

Nombre de Producto

thanks again,

dan



 -Original Message-
 From: Eric Rasmussen [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 13, 2001 3:56 PM
 To: [EMAIL PROTECTED]
 Subject: Re: can someone post an example of bean:message using
 parametric replacement


 ok, let me try again.

 in ApplicationResources.properties:
 error.field.required=Field {0} is required.

 in Action class; perform() method:
 ActionErrors errors = new ActionErrors();
 ...
 try {
   [parse field]
   [if field is required, but is not found] throw new
 ParseException("[field
 name]");
 } catch(ParseException pe) {
   errors.add("field", new ActionError("error.field.required",
 pe.getMessage());
   saveErrors(request, errors);
   return mapping.findForward("failure");
 }

 The {0} will be replaced by the value returned by 'e.getMessage()', so if
 [field name] is Address, the error message should read 'Field Address is
 required'.

 Hope this helps (more than my last response),
 - eric

 ----- Original Message -
 From: "Daniel Toms" [EMAIL PROTECTED]
 To: "Struts-User" [EMAIL PROTECTED]
 Sent: Friday, April 13, 2001 2:59 PM
 Subject: can someone post an example of bean:message using parametric
 replacement


  Hi,
 
  Can someone post a concrete example of a bean:message ... tag
  using parametric replacements and also post the corresponding lines
  from the properties file.  I am having some difficulty understanding it.
 
  thanks,
 
  dan
 
 
 





how to access related ActionForm from within .jsp?

2001-04-05 Thread Daniel Toms

I am having a common problem all over the place.
Struts allows you to associate a bean(the ActionForm)
with a given .jsp.  It then magically gets and sets
input fields for you.  Great.

But all of the other struts tags require a reference
to a bean by name, using the name="foo" argument
to the tag.

My problem is, I want to reference the bean associated
with my jsp, so that when I want to iterated over a collection
it contains, I can do so without having to know the bean's name.

example:


public final class FooForm extends ActionForm
{
public Collection bar;

public Collection getBar()
{
return bar;
}

public void setBar(Collection b
{
this.bar = b;
}
}

then in my jsp:

  logic:iterate name="???" id="criterion"
TR

  TDbean:write name="criterion" property="propertyName"//TD
  TDbean:write name="criterion" property="operator"//TD
  TDbean:write name="criterion" property="propertyValue"//TD
   /TR
/logic:iterate

So the iterate tag doesn't work because it wants a bean by name, but is
there something I haven't gotten that will make struts use the bean 
associated with the jsp and not one specified by name?  

thanks,

dan




RE: how to access related ActionForm from within .jsp?

2001-04-05 Thread Daniel Toms

Thanks for your advice.  I really just wanted
to prevent having to duplicate hard coded form bean
names, i.e. in my jsps and in the config.xml.

I wrote a tag to get it from the action mapping,
but alas, that didn't work either.  For one, my
action mapping was null(probably some misconfig on
my part).  Secondly, it looks like when you
nest a custom tag within the attribute of another
custom tag, it doesn't get evaluated, so
doing logic: iterate name="mylib:getFormBeanName /" ... /
won't work anyway.  Although this works fine for html tags.

thanks,

dan


 -Original Message-
 From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 05, 2001 12:11 PM
 To: [EMAIL PROTECTED]
 Subject: RE: how to access related ActionForm from within .jsp?


 The form bean is associated with an action, not a jsp. The jsp may contain
 an html:form which references an action, thereby gaining access
 to the form
 associated with that action. A jsp could have multiple html:forms.

 The form bean associated with the action is available in request scope for
 the jsp but I don't know how you would get access to it without using the
 name of the form. Is there a struts tag that will get actionmapping values
 when given the name of the action? That would allow you to get
 the form bean
 name using the same action used by the html:form.

 Maybe you could use the bean:struts tag to get the action mapping and then
 get the form from that.

 Hal

  -Original Message-
  From: Daniel Toms [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, April 05, 2001 2:50 PM
  To: Struts-User
  Subject: how to access related ActionForm from within .jsp?
 
 
  I am having a common problem all over the place.
  Struts allows you to associate a bean(the ActionForm)
  with a given .jsp.  It then magically gets and sets
  input fields for you.  Great.
 
  But all of the other struts tags require a reference
  to a bean by name, using the name="foo" argument
  to the tag.
 
  My problem is, I want to reference the bean associated
  with my jsp, so that when I want to iterated over a collection
  it contains, I can do so without having to know the bean's name.
 
  example:
 
 
  public final class FooForm extends ActionForm
  {
  public Collection bar;
 
  public Collection getBar()
  {
  return bar;
  }
 
  public void setBar(Collection b
  {
  this.bar = b;
  }
  }
 
  then in my jsp:
 
logic:iterate name="???" id="criterion"
  TR
 
TDbean:write name="criterion" property="propertyName"//TD
TDbean:write name="criterion" property="operator"//TD
TDbean:write name="criterion" property="propertyValue"//TD
 /TR
  /logic:iterate
 
  So the iterate tag doesn't work because it wants a bean by
  name, but is
  there something I haven't gotten that will make struts use the bean
  associated with the jsp and not one specified by name?
 
  thanks,
 
  dan