Author Login
Post Reply
user Digest 16 May 2008 15:11:43 -0000 Issue 8032
Topics (messages 186498 through 186520):
Struts validator framework
186498 by: Zhang, Larry (L.)
186499 by: Givler, Eric
How to change automatic type conversion error message
186500 by: Arpan Debroy
186507 by: Alberto A. Flores
[Struts 2] Switching Color in every row
186501 by: jeto
186504 by: volker.magiccode.eu
186506 by: jeto
186508 by: volker.magiccode.eu
186517 by: jeto
No JavaScript in s:div
186502 by: Håken Stark
186514 by: Yoge
Re: [Struts 2] Video Action
186503 by: Jeromy Evans
Display the Image from the Database
186505 by: Vaani
186512 by: Alberto A. Flores
186513 by: Jay Bose
[struts2]how to configure the web app
186509 by: kindlerm.arcor.de
186510 by: Jim Kiley
186511 by: kindlerm.arcor.de
186515 by: Giovanni Azua
186516 by: Jim Kiley
186520 by: dusty
Re: [Struts 2] Simple combobox behaviour
186518 by: Milan Milanovic
186519 by: Milan Milanovic
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)
----------------------------------------------------------------------

Attachment:
user_186498.ezm (zipped)
Say if I have two text fields, one label is Please enter name:, and the
other label is Please enter SSN:. In struts validator framework, if I
need to validate these two fields using required validator, is there any
way to relate the field label to the message? Or does struts validator
support displaying the validation message right next to the field (so
that the user easily know which fields are invalid)?
Thank you very much.

Attachment:
user_186499.ezm (zipped)You define the field label using an argument, i.e.
<field property="username" depends="required">
<arg0 key="prompt.username"/>
</field>
So the validator is using the field's label to fill in the message. The default message for errors.required is:
errors.required={0} is required.
So, it will replace {0} with the prompt.username entry that also appears as a resource.
To display the error next to the field, you could place an <html:errors property="username" /> next to the field. IF you do this though, realize that Struts is going to place the errors.header, errors.footer, errors.prefix and errors.suffix around the items. If you use the defaults that would not look right next to a field - fine for the top of the page, but not for a field. You'll have to change them.
Otherwise, you could use an <html:messages> tag specific for that field and then format the html yourself as it iterates one (or possibly several) error messages for each field.
Good luck,
Eric
-----Original Message-----
From: Zhang, Larry (L.) [mailto:lzhang20@(protected)]
Sent: Thu 5/15/2008 6:14 PM
To: Struts Users Mailing List
Cc:
Subject: Struts validator framework
Say if I have two text fields, one label is Please enter name:, and the
other label is Please enter SSN:. In struts validator framework, if I
need to validate these two fields using required validator, is there any
way to relate the field label to the message? Or does struts validator
support displaying the validation message right next to the field (so
that the user easily know which fields are invalid)?
Thank you very much.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_186500.ezm (zipped)In my application "id" attribute is int type of "Group" bean.
In my JSP I have written like that :-
<s:textfield name="group.id" value="%{group.id}"/>
Now if user puts a string into this text field, then error message come like
that
*invalid value for the field group.id
But I want to show the error message with only "id" not "group.id".
Is there anybody, who can show me any example how to do that.
*

Attachment:
user_186507.ezm (zipped)Read the section "Type Conversion Error Handling" in:
http://struts.apache.org/2.x/docs/type-conversion.html
You need to define an "invalid.fieldvalue.<your property>" to do custom
type conversion error.
Arpan Debroy wrote:
> In my application "id" attribute is int type of "Group" bean.
>
> In my JSP I have written like that :-
>
> <s:textfield name="group.id" value="%{group.id}"/>
>
> Now if user puts a string into this text field, then error message come like
> that
>
> *invalid value for the field group.id
>
> But I want to show the error message with only "id" not "group.id".
>
> Is there anybody, who can show me any example how to do that.
> *
>
--
Alberto A. Flores
http://www.linkedin.com/in/aflores

Attachment:
user_186501.ezm (zipped)
Hi,
Im looking for a nice and easy way to alter the color of every second
textfield.
We are yousing a custom theme to render the textfields including a tablerow.
Is something like this possible?
<s:textfield cssClass="%{++itemcount % 2 = 0 ? blue : red}" ...
Regards
jeto
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_186504.ezm (zipped)Hi,
if you are using an s:iterator, you can do that like this:
<s:iterator id="iteratorId" value="myList" status="status">
<s:if test="#status.odd">
<s:set name="class" value="'rowdark'" />
</s:if>
<s:else>
<s:set name="class" value="'rowlight'" />
</s:else>
<tr class="${class}">
...
</tr>
</s:iterator>
Hope that helps....
Volker
Hi,
Im looking for a nice and easy way to alter the color of every second
textfield.
We are yousing a custom theme to render the textfields including a tablerow.
Is something like this possible?
<s:textfield cssClass="%{++itemcount % 2 = 0 ? blue : red}" ...
Regards
jeto
--
View this message in context:
http://www.nabble.com/-Struts-2--Switching-Color-in-every-row-tp17268950p1726895
0.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_186506.ezm (zipped)
Volker Karlmeier wrote:
>
> Hi,
>
> if you are using an s:iterator, you can do that like this:
>
> <s:iterator id="iteratorId" value="myList" status="status">
>
> <s:if test="#status.odd">
> <s:set name="class" value="'rowdark'" />
> </s:if>
> <s:else>
> <s:set name="class" value="'rowlight'" />
> </s:else>
>
> <tr class="${class}">
> ...
> </tr>
> </s:iterator>
>
> Hope that helps....
>
> Volker
>
>
Thanks for your help but I m not using an iterator in this table.
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_186508.ezm (zipped)Hi,
then you could have this managed by your action class creating
a getter method for your counter.
Maybe something like that:
Action.class:
public void initCounter() {
this.counter=0;
}
public int getCounter() {
return counter++;
}
Your JSP:
<s:if test="counter%2!=0">
<s:set name="class" value="'rowdark'" />
</s:if>
<s:else>
<s:set name="class" value="'rowlight'" />
</s:else>
Might work :)
Volker
Volker Karlmeier wrote:
>
> Hi,
>
> if you are using an s:iterator, you can do that like this:
>
> <s:iterator id="iteratorId" value="myList" status="status">
>
> <s:if test="#status.odd">
> <s:set name="class" value="'rowdark'" />
> </s:if>
> <s:else>
> <s:set name="class" value="'rowlight'" />
> </s:else>
>
> <tr class="${class}">
> ...
> </tr>
> </s:iterator>
>
> Hope that helps....
>
> Volker
>
>
Thanks for your help but I m not using an iterator in this table.
--
http://www.nabble.com/-Struts-2--Switching-Color-in-every-row-tp17268950p1727173
4.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_186517.ezm (zipped)
Volker Karlmeier wrote:
>
> Hi,
>
> then you could have this managed by your action class creating
> a getter method for your counter.
>
> Maybe something like that:
>
> Action.class:
>
> public void initCounter() {
> this.counter=0;
> }
>
> public int getCounter() {
> return counter++;
> }
>
>
> Your JSP:
>
> <s:if test="counter%2!=0">
> <s:set name="class" value="'rowdark'" />
> </s:if>
> <s:else>
> <s:set name="class" value="'rowlight'" />
> </s:else>
>
>
> Might work :)
>
> Volker
>
>
Yes you are right...might work :-) but not very nice. Putting such things
into an action is not the right way I think. Is there no way doing this with
freemarker themes.
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_186502.ezm (zipped)Hi,
Are there any solution to these issues:
http://issues.apache.org/struts/browse/WW-1766
http://issues.apache.org/struts/browse/WW-2501
I'm still not able to execute any Javascript included from remote content. Same issues persists in both Struts 2.0.11.1 and 2.1.2. Could someone give me some input on this issues, especially issue WW-2501, since the comment text says 'removed'?
-Håken

Attachment:
user_186514.ezm (zipped)set executeScripts="true" in s:div tag.
For ex
<s:div theme="ajax" href="/myapp.do" loadingText="Loading..."
executeScripts="true"></s:div>
--Yoge
http://zoho.com
On Fri, May 16, 2008 at 12:50 PM, Håken Stark <haaken.stark@(protected)>
wrote:
> Hi,
>
> Are there any solution to these issues:
>
> http://issues.apache.org/struts/browse/WW-1766
> http://issues.apache.org/struts/browse/WW-2501
>
> I'm still not able to execute any Javascript included from remote content.
> Same issues persists in both Struts 2.0.11.1 and 2.1.2. Could someone give
> me some input on this issues, especially issue WW-2501, since the comment
> text says 'removed'?
>
> -Håken
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
--
--Yoge
91-9840425388

Attachment:
user_186503.ezm (zipped)Yousri BENDI ABDALLAH wrote:
> Hello ,
>
> I have a problem with the integration of a video (wmv format) within a JSP
> page. To that end I use the tag html <object> which allows me to integrate
> my video played with Windows Media Player, these videos are stored on an
> application server Weblogic 8.1. But I faced the following problem: my tag
> object should recover within its attribute "src" a stream obtained from an
> action struts 2. If a recovery this flow is done smoothly in the event of a
> gif or jpeg image, the same action can not play the video in the drive
> (displaying a black screen on the player without the possibility of
> reading).
>
>
> Viewing an image (runs smoothly):
>
> <img src="/DLImage.action?file=chateau.gif" />
>
> Viewing a video:
>
> <object type="video/x-ms-wmv" width="320" height="255">
> <param name="src" value="/Download.action?file=test.wmv" />
> <param name="autoStart" value="0" />
> </ object>
>
> The actions DLImage.action and Download.action make available a flow-type
>
java.io.FileInputStream from the files stored on the server.
>
> Please give me your comments if you've already encountered a similar problem
> or if you have a solution or alternative to propose, I would be grateful!
>
>
>
I suggest you use FireBug or the HttpHeaders plugin for FireFox to
examine the header for the response from your action compared to a wmv
served directly by the container. It's likely that the
Content-Disposition header, Content-Size or Content-Length is
incorrect. You'll probably need to change the parameters passed to the
StreamResult.

Attachment:
user_186505.ezm (zipped)
Hi i am new to struts...
how to display the created image from database.i got the image in byte
array format. can any one tell me
how to convert the byte array format into image format and display it using
struts.
Thanks in Advance
With Regards
vani
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_186512.ezm (zipped)Please refer to:
http://struts.apache.org/2.0.11.1/docs/how-can-we-display-dynamic-or-static-images-that-can-be-provided-as-an-array-of-bytes.html
The search engine in the wiki is a pretty good tool :)
I actually found that method very useful.
Vaani wrote:
> Hi i am new to struts...
>
> how to display the created image from database.i got the image in byte
> array format. can any one tell me
> how to convert the byte array format into image format and display it using
> struts.
>
> Thanks in Advance
>
> With Regards
> vani
>
>
--
Alberto A. Flores
http://www.linkedin.com/in/aflores

Attachment:
user_186513.ezm (zipped)Vaani, try the Stream result type - http://struts.apache.org/2.x/docs/stream-result.html
--- Vaani <vani.m16@(protected):
>
> Hi i am new to struts...
>
> how to display the created image from database.i got the image in byte
> array format. can any one tell me
> how to convert the byte array format into image format and display it using
> struts.
>
> Thanks in Advance
>
> With Regards
> vani

Attachment:
user_186509.ezm (zipped)Hi,
I am new to Struts2 and stumbling immediately.
I want to have an initialization routine in my web app which will connect to a data base etc. at startup time. This routine needs some parameters (e. g. the path of a config file to be read). How can I access such external information?
With Servlets I would normally implement a ServletContextListener which would get its information as an init-param from web.xml.
But for Struts2 there is no <servlet> spec where I could put it.
Writing Struts1 applications I typically utilized a plugin which could read parameters from struts-config.xml. Maybe this is still possible, but the Struts2 plugin mechanism seems to be too powerful (or just overwhelming) for me.
What is the preferred way?
Thanks
Martin

Attachment:
user_186510.ezm (zipped)Hi Martin,
This seems like an ideal situation for using Spring dependency injection.
Are you familiar with Spring at all?
jk
On Fri, May 16, 2008 at 8:04 AM, <kindlerm@(protected):
> Hi,
>
> I am new to Struts2 and stumbling immediately.
>
> I want to have an initialization routine in my web app which will connect
> to a data base etc. at startup time. This routine needs some parameters (e.
> g. the path of a config file to be read). How can I access such external
> information?
>
> With Servlets I would normally implement a ServletContextListener which
> would get its information as an init-param from web.xml.
> But for Struts2 there is no <servlet> spec where I could put it.
>
> Writing Struts1 applications I typically utilized a plugin which could read
> parameters from struts-config.xml. Maybe this is still possible, but the
> Struts2 plugin mechanism seems to be too powerful (or just overwhelming) for
> me.
>
> What is the preferred way?
>
> Thanks
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
--
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

Attachment:
user_186511.ezm (zipped)Hi Jim,
could you detail on this? I am not really familiar with Spring and at first sight it looks much too mighty for just some little initialization, but maybe its providing the hook I am looking for.
Martin
----- Original Nachricht ----
Von: Jim Kiley <jhkiley@(protected)>
An: Struts Users Mailing List <user@(protected)>
Datum: 16.05.2008 14:30
Betreff: Re: [struts2]how to configure the web app
> Hi Martin,
>
> This seems like an ideal situation for using Spring dependency injection.
> Are you familiar with Spring at all?
>
> jk
>
> On Fri, May 16, 2008 at 8:04 AM, <kindlerm@(protected):
>
> > Hi,
> >
> > I am new to Struts2 and stumbling immediately.
> >
> > I want to have an initialization routine in my web app which will connect
> > to a data base etc. at startup time. This routine needs some parameters
> (e.
> > g. the path of a config file to be read). How can I access such external
> > information?
> >
> > With Servlets I would normally implement a ServletContextListener which
> > would get its information as an init-param from web.xml.
> > But for Struts2 there is no <servlet> spec where I could put it.
> >
> > Writing Struts1 applications I typically utilized a plugin which could
> read
> > parameters from struts-config.xml. Maybe this is still possible, but the
> > Struts2 plugin mechanism seems to be too powerful (or just overwhelming)
> for
> > me.
> >
> > What is the preferred way?
> >
> > Thanks
> >
> > Martin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
>
>
> --
> Jim Kiley
> Technical Consultant | Summa
> [p] 412.258.3346 [m] 412.445.1729
> http://www.summa-tech.com
>

Attachment:
user_186515.ezm (zipped)hi Martin,
I here, do not use Spring nor hibernate and indeed need defining a
ServletContextListener implementation that I configure in web.xml that
initializes database connections etc.
In an ideal world:
- You are starting a new web application project from scratch
- You are open to see best practices and learn by example
- You do not have constraints on which technologies to use (e.g. Spring,
Hibernate, Sitemesh, etc)
THEN
Please do yourself a favor an use AppFuse, it will give you a beautiful
Struts 2 application setup out of the box including user-management and
authentication on top of MySQL database. The only thing I can complain
about it though is its usage of sitemesh where I prefer tiles. Maybe
their GenericDao implementations could be polished as well.
Checkout their web site: http://appfuse.org/display/APF/AppFuse+QuickStart
Basically you only need to:
1) Install maven & subversion & MySQL
2) mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes
-DarchetypeArtifactId=appfuse-basic-struts
-DremoteRepositories=http://static.appfuse.org/releases^
-DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject
3) cd myproject and execute "mvn appfuse:full-source"
Then you can start a full forensic analysis on it :) and get the idea
how to structure a beautiful web app :) they even offer a tutorial how
to get you going from that point on.
HTH,
regards,
Giovanni
kindlerm@(protected):
> Hi,
>
> I am new to Struts2 and stumbling immediately.
>
> I want to have an initialization routine in my web app which will connect to a data base etc. at startup time. This routine needs some parameters (e. g. the path of a config file to be read). How can I access such external information?
>
> With Servlets I would normally implement a ServletContextListener which would get its information as an init-param from web.xml.
> But for Struts2 there is no <servlet> spec where I could put it.
>
> Writing Struts1 applications I typically utilized a plugin which could read parameters from struts-config.xml. Maybe this is still possible, but the Struts2 plugin mechanism seems to be too powerful (or just overwhelming) for me.
>
> What is the preferred way?
>
> Thanks
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_186516.ezm (zipped)Spring is kind of mighty to use just for some initialization parameters;
however, using Spring for dependency injection provides greatly improved
management of object dependencies for the rest of your app.
My current app is a Spring / Struts 2 app running on Tomcat.
Here is a quick overview of how I'm using Spring with Struts 2 -- I will
address your specific question after the basics below.
In my Spring configuration file (applicationContext.xml), I have all my
various beans wired together, including my Struts actions. So, for
instance, I have a UserDetailsService bean that has a reference to my
UserDao, and a UserDetailsAction that has a reference to the
UserDetailsService:
<bean id="userDao" class="com.bogus.dao.UserDaoImpl"/>
<bean id="userDetailsService"
class="com.bogus.service.UserDetailsServiceImpl">
<property name="userDao" ref="userDao"/>
</bean>
<bean id="userDetailsAction" class="com.bogus.action.UserDetailsAction">
<property name="userDetailsService" ref="userDetailsService"/>
</bean>
Then, in struts.xml, I don't have a direct reference to my UserDetailsAction
class -- instead I have a reference to the Spring-managed bean:
<action name="userDetail" class="userDetailAction" method="input">
<result name="success" type="redirect-action">userList</result>
<result name="input">/WEB-INF/secure/admin/userDetail.jsp</result>
</action>
Now -- as to your specific question. If your database connections are
handled by an object of a specific class, you can use Spring to inject the
necessary values into your database connector object. Something like this:
<bean id="databaseConnector" class="com.bogus.db.Connector">
<property name="driverClassName" value="
com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/" />
<property name="username" value="dbUser" />
<property name="password" value="password" />
</bean>
This is actually not ideal if you're going to be migrating this application
through various environments. Better than this would be to set up a context
file in each environment and refer to it in your Spring configuration. But
if you're in the early dev stages, this works well.
jk
On Fri, May 16, 2008 at 8:49 AM, <kindlerm@(protected):
> Hi Jim,
>
> could you detail on this? I am not really familiar with Spring and at first
> sight it looks much too mighty for just some little initialization, but
> maybe its providing the hook I am looking for.
>
> Martin
>
>
> ----- Original Nachricht ----
> Von: Jim Kiley <jhkiley@(protected)>
> An: Struts Users Mailing List <user@(protected)>
> Datum: 16.05.2008 14:30
> Betreff: Re: [struts2]how to configure the web app
>
> > Hi Martin,
> >
> > This seems like an ideal situation for using Spring dependency injection.
> > Are you familiar with Spring at all?
> >
> > jk
> >
> > On Fri, May 16, 2008 at 8:04 AM, <kindlerm@(protected):
> >
> > > Hi,
> > >
> > > I am new to Struts2 and stumbling immediately.
> > >
> > > I want to have an initialization routine in my web app which will
> connect
> > > to a data base etc. at startup time. This routine needs some parameters
> > (e.
> > > g. the path of a config file to be read). How can I access such
> external
> > > information?
> > >
> > > With Servlets I would normally implement a ServletContextListener which
> > > would get its information as an init-param from web.xml.
> > > But for Struts2 there is no <servlet> spec where I could put it.
> > >
> > > Writing Struts1 applications I typically utilized a plugin which could
> > read
> > > parameters from struts-config.xml. Maybe this is still possible, but
> the
> > > Struts2 plugin mechanism seems to be too powerful (or just
> overwhelming)
> > for
> > > me.
> > >
> > > What is the preferred way?
> > >
> > > Thanks
> > >
> > > Martin
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > > For additional commands, e-mail: user-help@(protected)
> > >
> > >
> >
> >
> > --
> > Jim Kiley
> > Technical Consultant | Summa
> > [p] 412.258.3346 [m] 412.445.1729
> > http://www.summa-tech.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
--
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

Attachment:
user_186520.ezm (zipped)Struts2 doesn't stop you from implementing a ServletContextListener. In
fact in the Appfuse Struts2 application there is a StartupListener (extends
ServletContextListener) that does what you talk about.
It just so happens that Appfuse also uses Spring to configure its services
including its database connections. So in this StartupListener there is
some configuration read from web.xml
ServletContext context = event.getServletContext();
String something = context.getInitParameter(name_of_paramerter);
But it also initializes things like static drop-down lists for HTML selects.
It does this by connecting to the database using Spring managed beans. The
database related Spring managed beans are configured as such:
<bean id="propertyConfigurer"
class="
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- JNDI DataSource for J2EE environments -->
<!--<jee:jndi-lookup id="dataSource"
jndi-name="java:comp/env/jdbc/appfuse"/>-->
<bean id="dataSource" class="
org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxActive" value="100"/>
<property name="maxWait" value="1000"/>
<property name="poolPreparedStatements" value="true"/>
<property name="defaultAutoCommit" value="true"/>
</bean>
It also uses Hibernate, so there is a SessionFactory bean that references
this DataSource bean and then DAO classes that reference the SessionFactory
bean, but that is beyond this discussion I think.
What you see above is how an external property file is declared and then
those values included in configuration of a Spring managed bean.
The ServletContextListener gets these Spring beans by doing the following:
ServletContext context = event.getServletContext();
ApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(context);
(BasicDataSource) ds = ctx.getBean("dataSource");
The last interesting part of this example/topic is that the listener looks
up the list of values from the database and then puts them into the
ServletContext to be access later by struts tags.
List options = ...some jdbc that returns a list....
context.setAttribute("optionListName",options);
Then later on in a page:
<s:select list="#attr.optionListName" .... /> (Uses OGNL to get
something from the ServletContext)
Martin Kindler wrote:
>
> Hi,
>
> I am new to Struts2 and stumbling immediately.
>
> I want to have an initialization routine in my web app which will connect
> to a data base etc. at startup time. This routine needs some parameters
> (e. g. the path of a config file to be read). How can I access such
> external information?
>
> With Servlets I would normally implement a ServletContextListener which
> would get its information as an init-param from web.xml.
> But for Struts2 there is no <servlet> spec where I could put it.
>
> Writing Struts1 applications I typically utilized a plugin which could
> read parameters from struts-config.xml. Maybe this is still possible, but
> the Struts2 plugin mechanism seems to be too powerful (or just
> overwhelming) for me.
>
> What is the preferred way?
>
> Thanks
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_186518.ezm (zipped)I'm just not sure when I put listValue = "name" and listKey="id" I get
and emtpy combo box with exactly 4 places (it have value option good) ?
One more thing, if I have object Person buyer; in my Fruit class (with
get/set methods), and I have Fruit fruit object in my action class,
where I also have List<Person>allBuyers in my action class. How can I
define combo box so that when buyer is selected, that Person object should
be set to my fruit.buyer object ?
When I removed listKey then it works good. But I now have the same
problem with my datetimepicker field. I have "date" attrib (of type
java.util.Date with get/set methods) in my Fruit class. I have defined it in
jsp like this:
<s:daettimepicker name="fruit.date" id="fruit.date"
displayFormat="dd.MM.yyyy" label="Date" type="date"/>
?
--
Thx, Milan
Felipe Lorenz <felipe.lorenz@(protected):
Ok.. if i get your idea... the list yout want to put in combobox is
fruit.buyers, hummmm?
Then, try it:
listKey="personId" name="fruit.buyers" emtpyOption="false"
hedaerKey="none"/>
if you have the object fruit, then:
listValue="personName" listKey="personId" name="fruit.buyers"
emtpyOption="false" hedaerKey="none"/>
maybe the name is not correct. Try chage the attr name to person, for
example.
listValue="personName" listKey="personId" name="person" emtpyOption="false"
hedaerKey="none"/>
On Thu, May 15, 2008 at 6:05 PM, Milan Milanovic
wrote:
> When I set listKey="fruit.buyers.id", I get a empty combo box, but with
> correct number of emtpy spaces (in my case 4) ?
>
> --
> Thanks, Milan
>
> Felipe Lorenz wrote: You need eht attribute
> "listKey" where you'll put the Person id!!!
>
> see:
>
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/components/Select.html
>
> On Thu, May 15, 2008 at 5:19 PM, Milan Milanovic
> wrote:
>
> > Hi,
> >
> > I have simple class Fruit, that have "id" (long), "name" (String), and
> > "buyers" List of
> . In my action class I have Fruit fruit; object
> > with get/set methods.
> >
> > In my jsp I have combo box defined like this:
> >
> >
> > emtpyOption="false" value = "fruit.buyers" hedaerKey="none"
> > multiple="false"/>
> >
> > and when I sumbit form that contain this combo box, it generates
> following
> > error:
> >
> > 22:16:18,281 ERROR
> >
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204 -
> > ParametersInterceptor - [setParameters]: Unexpected Exception caught
> setting
> > 'fruit.buyers' on class 'com.myproject.actions.FruitAction': Error
> setting
> > expression 'fruit.buyers' with value '[Ljava.lang.String;@(protected)'
> >
> >
> >
> >
>
>
>
>
>

Attachment:
user_186519.ezm (zipped)I fixed my first problem, it was naming issue. But I still have this question:
If I have object Person buyer; in my Fruit class (with
get/set methods), and I have Fruit fruit object in my action class,
where I also have List<Person>allBuyers in my action class. How can I
define combo box so that when buyer is selected, that Person object
should be set to my fruit.buyer object ?
Now I have the same
problem with my datetimepicker field. I have "date" attrib (of type
java.util.Date with get/set methods) in my Fruit class. I have defined
it in jsp like this:
<s:daettimepicker name="fruit.date" id="fruit.date"
displayFormat="dd.MM.yyyy" label="Date" type="date"/>
--
Thx, Milan
Milan Milanovic <milanmilanovich@(protected):
I'm just not sure when I put listValue = "name" and listKey="id" I get
and emtpy combo box with exactly 4 places (it have value option good) ?
One more thing, if I have object Person buyer; in my Fruit class (with
get/set methods), and I have Fruit fruit object in my action class,
where I also have List
allBuyers in my action class. How can I
define combo box so that when buyer is selected, that Person object should
be set to my fruit.buyer object ?
When I removed listKey then it works good. But I now have the same
problem with my datetimepicker field. I have "date" attrib (of type
java.util.Date with get/set methods) in my Fruit class. I have defined it in
jsp like this:
displayFormat="dd.MM.yyyy" label="Date" type="date"/>
?
--
Thx, Milan
Felipe Lorenz wrote:
Ok.. if i get your idea... the list yout want to put in combobox is
fruit.buyers, hummmm?
Then, try it:
listKey="personId" name="fruit.buyers" emtpyOption="false"
hedaerKey="none"/>
if you have the object fruit, then:
listValue="personName" listKey="personId" name="fruit.buyers"
emtpyOption="false" hedaerKey="none"/>
maybe the name is not correct. Try chage the attr name to person, for
example.
listValue="personName" listKey="personId" name="person" emtpyOption="false"
hedaerKey="none"/>
On Thu, May 15, 2008 at 6:05 PM, Milan Milanovic
wrote:
> When I set listKey="fruit.buyers.id", I get a empty combo box, but with
> correct number of emtpy spaces (in my case 4) ?
>
> --
> Thanks, Milan
>
> Felipe Lorenz wrote: You need eht attribute
> "listKey" where you'll put the Person id!!!
>
> see:
>
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/components/Select.html
>
> On Thu, May 15, 2008 at 5:19 PM, Milan Milanovic
> wrote:
>
> > Hi,
> >
> > I have simple class Fruit, that have "id" (long), "name" (String), and
> > "buyers" List of
> . In my action class I have Fruit fruit; object
> > with get/set methods.
> >
> > In my jsp I have combo box defined like this:
> >
> >
> > emtpyOption="false" value = "fruit.buyers" hedaerKey="none"
> > multiple="false"/>
> >
> > and when I sumbit form that contain this combo box, it generates
> following
> > error:
> >
> > 22:16:18,281 ERROR
> >
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204 -
> > ParametersInterceptor - [setParameters]: Unexpected Exception caught
> setting
> > 'fruit.buyers' on class 'com.myproject.actions.FruitAction': Error
> setting
> > expression 'fruit.buyers' with value '[Ljava.lang.String;@(protected)'
> >
> >
> >
> >
>
>
>
>
>