Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 26 Mar 2008 09:36:18 -0000 Issue 7944

user-digest-help

2008-03-26


Author LoginPost Reply

user Digest 26 Mar 2008 09:36:18 -0000 Issue 7944

Topics (messages 184610 through 184639):

Re: HashMap and updates
 184610 by: Laurie Harper

Re: Actions/DAO interaction getting messy...
 184611 by: Laurie Harper
 184615 by: Adam Hardy

Re: Javascript error using struts select tag
 184612 by: Laurie Harper

Best way to get request information
 184613 by: mojoRising
 184614 by: Laurie Harper

The validator does not work
 184616 by: Chen Chunwei
 184617 by: Chen Chunwei

Re: [struts] S2: Actions/DAO interaction getting messy...
 184618 by: Dale Newfield

Replacement For MessageResourceConfig and MessageResourceFactory in struts-2
 184619 by: sandyvj83

Struts 2.1 & AjaxAnywhere
 184620 by: Shoaib Gauhar

Re: Struts2 Annotation based Validation
 184621 by: Tauri Valor
 184622 by: Tauri Valor
 184623 by: Lukasz Lenart
 184626 by: Tauri Valor
 184628 by: Tauri Valor
 184632 by: Lukasz Lenart

How to enable the client side validation?
 184624 by: Chen Chunwei
 184625 by: Nils-Helge Garli Hegvik
 184629 by: Chen Chunwei
 184630 by: Antonio Petrelli
 184633 by: Chen Chunwei
 184634 by: Antonio Petrelli
 184635 by: Chen Chunwei
 184636 by: Antonio Petrelli
 184637 by: Chen Chunwei
 184639 by: Antonio Petrelli

<s:if> Problem
 184627 by: Marc Eckart
 184638 by: Lukasz Lenart

RE : How to eliminate an entry from an array with s2 tags
 184631 by: Ezequiel Puig

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_184610.ezm (zipped)
Kalpesh Modi wrote:
> Hi,
>
> I am having a problem in updates.
> I have a base class Employee.java. I have subclasses HourlyEmployee.java, ContractEmployee.java, FullTimeEmployee.java.
> I display these three types of employees under 3 tabs on my JSP.
> I create 3 lists for each type of employees and put these lists in a HashMap with different keys.
>
> Map employeeMap = new HashMap();
> employeeMap.put ("HE", hourlyEmployeeList);
> employeeMap.put ("CE", contractEmployeeList);
> employeeMap.put ("FE", fullTimeEmployeeList);
>
> I am able to display the list of employees properly. But when I change the values and submit the form, the new values dont show up in the action.

That's definately doable, so it's probably a simple tag usage error. You
don't include your code, so it's impossible to say where the problem is,
but I'd suggest you start by simplifying things down; start by making
sure you can edit a single employee; then get it working with a list of
employees; then with a list in a map. Along the way you'll probably
discover which asspect of your data addressing is incorrect.

L.


Attachment: user_184611.ezm (zipped)
Eric D Nielsen wrote:
> I'm starting to get some rather stinky code in one of my projects and wanted to
> ask for some advice. (
>
> Its a Struts2/Spring2/JPA(Hibernate) based project. I'm using a slightly
> modified version of the Generic DAO pattern shown in the Java persistence with
> Hibernate book and/or the IBM ThoughtWorks very similar example. (Modified to
> allow Spring Based Injection of the JPA EntityManger, while falling back to a
> native Hibernate session inside the DAOs to allow a few more optimizations).
>
> So its basically
> Business Objects (POJOs) <---1:1---> DAOs
> which is a relatively normal pattern I beleive.
>
> Now I'm working on an Action that creates an object that contains lots of
> references to other objects. A bug tracker would be a reasonable facsimile of
> my domain object -- when creating a bug, you select a severity, a project, a
> module, a found in version, possibly you're assigning it to someone, etc. Most
> of these options come from a drop-down on the view page, however they are all
> backed by their own domain object -- ie its not just id/string display name
> lookup-table backing the drop down.
>
> So the form submits a whole suite of IDs or String natural keys and I need to
> build an Defect/Bug and then persist it. In building the Defect I need to
> convert all the keys to domain objects. This is where things begin to fall
> apart. To covert the keys to domain object seems to require injecting all the
> subordinate object DAOs into the Action, its not a big deal but its starting to
> feel like the subordinate DAOs are taking over the action. Furthermore, its
> slightly annoying from a performance stand-point that I need to retrieve all
> the objects from the DB, just to set a foreign key -- I will never be updating
> the details on the subordinate object from the master only changing which one
> I'm linked to. [As a side issue: this is a place where the Get (returning a
> proxy/lazy load thunk with only the ID set without hitting the DB) versus Load
> could be useful, but I've never seen any of the generic DAO approaches expose
> that level of control in their API -- does anyone know why?]
>
> Here's an example (not from live code, please ignore any minor typos)
> representing the current state of application and test code. Afterwards I'll
> list a few of the approaches I've considered for cleaning it up:
> AddBug.java
>
>   code:
>
>
>
>   public class AddBug extends ActionSupport {
>     private BugDAO bugService;
>     private UserDAO userService;
>     private ProjectDAO projectService;
>     private ModuleDAO moduleService;
>     private VersionDAO versionService;
>
>     private String submitterUsername;
>     private String assigneeUsername;
>     private Long projectID;
>     private Long moduleID;
>     private List<Long> affectedVersionIDs;
>
>     public String execute() {
>      Bug bug = new Bug();
>      // The following lines are what feel unclean to me
>      bug.setSubmitter(userService.findByUsername(getSubmitterUsername()));
>      bug.setAssignee(userService.findByUsername(getAssigneeUsername()));
>      bug.setProject(projectService.find(getProjectID()));
>      bug.setModule(moduleService.find(getModuleID()));
>      for( Long versionID : getAffectedVersionIDs()) {
>       bug.addAffectedVersion(versionService.find(versionID));
>      }
>      bugDAO.persist(bug);
>      return SUCCESS;
>     }
>
>     // This block of setters also seems to be wrong... Only the first one
>     // should really be required by this action I think....
>     public void setBugService(final BugDAO bs) {bugService=bs;}
>     public void setUserService(final UserDAO us) {userService=us;}
>     public void setProjectService(final ProjectDAO ps) {projectService=ps;}
>     public void setModuleService(final ModuleDAO ms) {moduleService=ms;}
>     public void setVersionService(final VersionDAO vs) {versionService=vs;}
>
>     public void setSubmitterUsername(final String username)
> {submitterUsername=username;}
>     public void setAssigneeUsername(final String username)
> {assigneeUsername=username;}
>     public void setProjectID(final Long id) {projectID=id;}
>     public void setModuleID(final Long id) {moduleID=id;}
>     public void setAffectedVersionIDs(final List<Long> ids)
> {affectedVersionIDs=ids;}
>
>     public String getSubmitterUsername() {return submitterUsername;}
>     public String getAssigneeUsername() {return assigneeUsername;}
>     public Long getProjectID() {return projectID;}
>     public Long getModuleID() {return moduleID;}
>     public List<Long> getAffectedVersionIDs() {return affectedVersionIDs;}
>   }
>
>
>
> TestAddBug.java
> (Sorry this is purely from memory so I know I'm missing some of my
> infrastructure)
>
>   code:
>
>
>     ....
>     public void testAddBug() {
>       String submitterUsername="TestUser";
>       String assigneeUsername="TestVictim";
>       User submitter=new User(submitterUsername);
>       User assignee=new User(assigneeUsername);
>       UserDAO userService = createMock(UserDAO.class);
>      
> expect(userService.findByUsername(submitterUsername)).andReturn(submitter);
>      
> expect(userService.findByUsername(assigneeUsername)).andReturn(assignee);
>
>      Long projectID =1L;
>      Project project = new Project(projectID,"Some Projectname");
>      ProjectDAO projectService = createMock(ProjectDAO.class);
>      expect(projectService.find(projectID)).andReturn(project);
>
>      Long moduleID=1L;
>      Module module = new Module(moduleID,"Some ModuleName");
>      ModuleDAO moduleService = createMock(ModuleDAO.class);
>      expect(moduleService.find(moduleID)).andReturn(module);
>
>      Long versionOneID=1L;
>      Long versionTwoID=2L;
>      Version versionOne = new Version(versionOneID,"A Version");
>      Version versionTwo = new Version(vertionTwoID,"Another Version");
>      List<Long> versionIDs = new ArrayList<Long>();
>      List<Version> versions = new ArrayList<Version>();
>      versionIDs.add(versionOneID);
>      versionIDs.add(versionTwoID);
>      versions.add(versionOne);
>      versions.add(versionTwo);
>      VersionDAO = versionService = createMock(VersionDAO.class);
>      expect(versionService.buildVersionlist(versionIDs)).andReturn(versions);
>
>      Bug bug = new Bug();
>      BugDAO bugService = createMock(BugDAO.class);
>      expect(bugService.persist(bug));
>      replay(userSerive);
>      replay(projectService);
>      replay(moduleService);
>      replay(versionService);
>      replay(bugService);
>
>      AddBug action = new AddBugAction();
>      action.setBugService(bugService);
>      action.setProjectService(projectService);
>      action.setModuleService(moduleService);
>      action.setVersionService(versionService);
>      action.setUserService(userService);
>
>      // In reality this would probably be pulled from the session map, but...
>      action.setSubmitterUsername(submitterUsername);
>
>      action.setAssigneeUsername(assigneeUsername);
>      action.setProjectID(projectID);
>      action.setModuleID(moduleID);
>      action.setAffectedVersionIDs(versionIDs);
>
>      assertEquals("success",action.execute());
>      verify(bugService);
>      verify(userService);
>      verify(projectService);
>      verify(moduleService);
>      verify(versionService);
>     }
>    ...
>
>
>
> OK. Now that you've seen the mess... I've thought of two ways to clean it up:
>
> 1) Introduce a business tier between the domain objects and the DAOs. Expose a
> buildBug call in this layer that takes in the keys and handles the promotion to
> subordinate domain objects. This business tier would need to have all the DAO
> injected into it. Actions would still have their most relevant DAO(s) injects,
> plus the business tier relevant objects. Testing the business tier would still
> require the mess of mocks, but at least the action only needs to mock the
> single call on the business tier. However I don't think this approach would
> play too well with migrating to a Model-Driven strategy in the future as the
> domain objects can't accept the bare keys. I'm also having a hard time figuring
> out what type of methods would end up in this layer -- it seems like mostly it
> will be these kinds of initial builders... Most of other use cases are either
> correctly cascaded/handled by Hibernate (updates/deletes) and the DAOs or they
> belong on the POJOs (real business logic)... Leading to a very anemic layer,
> which doesn't seem worth the added complexity...
>
> 2) Setup a series of type converters to promote the keys to objects on the
> incoming HTTP request end of things. The type converters would need access to
> the DAOs. Testing them should be rather simple as each singular one is simple.
> Testing the action no longer requires mocking the subordinate objects and I can
> just use POJOs there. I believe this approach would work with the Model-Driven
> idea, but it feels a little odd to me to mark up the domain object with
> HTTP-specific details.... then again the domain object is already annotated
> with Hibernate/JPA annotations so its not like its really 'pure'.. I've seen
> some talk on the mailing list of this approach, but it seems to have some
> "black holes" regarding converting back to string for redsplay at times.
>
> Comments, alternate approaches?

Adding a suite of type converters and a service layer would certainly
clean up your action code a lot. Your example action should shrink to
just a getBug()/setBug() method pair and a call to bugService.persist(),
more or less.

Your code seems to mix 'bugService' and 'bugDAO' freely, so it's worth
repeating the recommendation to introduce an intermediate service tier.
You bugService would take in an instance of Bug, fully populated
already. Therefore it's easy to unit test from there down. Your action
becomes trivial to test too, since it's doing very little once you have
all the data marshalling factored out into custom converters.

The final issue of database 'chattyness' should probably be ignored at
this stage; that's an performance/optimization issue, which you can
address later (once you've measured to determine if it's significant or
not) with the various caching strategies Hibernate provides for.

L.


Attachment: user_184615.ezm (zipped)
Eric D Nielsen on 25/03/08 14:29, wrote:
> Its a Struts2/Spring2/JPA(Hibernate) based project. I'm using a slightly
> modified version of the Generic DAO pattern shown in the Java persistence with
> Hibernate book and/or the IBM ThoughtWorks very similar example. (Modified to
> allow Spring Based Injection of the JPA EntityManger, while falling back to a
> native Hibernate session inside the DAOs to allow a few more optimizations).
>
> So its basically
> Business Objects (POJOs) <---1:1---> DAOs
> which is a relatively normal pattern I beleive.

Is it normal with that Generic DAO pattern to name the DAOs 'services'? In the
Domain-Driven-Design paradigm that I generally follow, the services are objects
which carry out operations that you don't want to specifically assign to one
domain object.

> [As a side issue: this is a place where the Get (returning a
> proxy/lazy load thunk with only the ID set without hitting the DB) versus Load
> could be useful, but I've never seen any of the generic DAO approaches expose
> that level of control in their API -- does anyone know why?]

that's a pure Hibernate thing, I think, not a JPA distinction.


> just use POJOs there. I believe this approach would work with the Model-Driven
> idea, but it feels a little odd to me to mark up the domain object with
> HTTP-specific details....

Yes it would do, but what do you mean by 'mark up the domain object with
HTTP-specific details'? I don't think you have to touch the domain objects to
code the re-construction of your incoming Bug POJO.

Regards
Adam

Attachment: user_184612.ezm (zipped)
Since html:submit doesn't emit any Javascrip, the error has to be in
your custom Javascript code. That came through somewhat unreadably
formatted, though, and you didn't include its dependencies so it's tough
to debug from here... I would strongly recommend installing Firefox +
Firebug and stepping through your code in the debugger to figure out the
problem.

L.

Joe Yuen wrote:
>
>
>
> I am trying to use the <html:select> tag in my jsp page but am getting the following javascript error,
>
> Microsoft JScript runtime error: Object expected.
>
> In my jsp page I have:
>
> <table align="left" class="tableGold">
>
> <tr>
>
> <th align="left" bgcolor="#EEE8AA"><font size="-1" color="#ff0000">*</font><bean:message key="table.head.category"/></th>
>
> </tr>
>
> <tr>
>
> <td align="center" valign="middle" >
>
> <div>
>
> <div style="{float: left;}" >
>
> <html:select styleId="category" property="devicecategoryid" onchange="selectDevOrStent()">
>
> <html:option value=""><bean:message key="select.list.device.category"/></html:option>
>
> <html:options collection="DeviceCategory" property="id" labelProperty="description"/>
>
> </html:select>
>
> </div>
>
> <div id="otherdev" style="{float: left; display: none; font-family: Arial, Helvetica, sans-serif; font-size: xx-small; vertical-align: middle; padding-left: 50px; line-height: 1.2em}">
>
> <html:text property="other" size="35" maxlength="60" onfocus="clearOther()" value = "Enter Device Description" />
>
> </div>
>
> </div>
>
> </td>
>
> </tr>
>
> </table>
>
>
>
> Here is the javascript funtion that is called when a onchange event is detected:
>
>
>
> function selectDevOrStent(){
>
> alert("In SelectDevOrStent");
>
> var category = id("category").options[id("category").selectedIndex].value;
>
> var categoryText = id("category").options[id("category").selectedIndex].text;
>
> //alert("categoryText = " + categoryText);
>
> if(categoryText == 'Stents'){
>
> //alert("Stent selected");
>
> id("stent").style.display = "block";
>
> id("dev").style.display = "none";
>
> id("otherdev").style.display = "none";
>
> getSelectList("category", "StentManufacturerSelect.do", stentmanufcallback);
>
> }else if(categoryText == 'Joint Replacement'){
>
> //alert("Joint Replacement selected");
>
> document.DeviceInputForm.devicetypeid.disabled='true';
>
> document.DeviceInputForm.manufacturer.disabled='true';
>
> document.DeviceInputForm.modelnumber.disabled='true';
>
> getSelectList("category", "DeviceLocationSelect.do?devicecategoryid=" + escape(id("category").value), locationcallback);
>
> id("dev").style.display = "block";
>
> id("stent").style.display = "none";
>
> id("otherdev").style.display = "none";
>
> }else if(categoryText == 'Other'){
>
> //alert("Other selected");
>
> id("otherdev").style.display = "block";
>
> id("stent").style.display = "none";
>
> id("dev").style.display = "none";
>
> }else{
>
> //alert("Stent not selected");
>
> id("stent").style.display = "none";
>
> id("dev").style.display = "block";
>
> id("otherdev").style.display = "none";
>
> getSelectList("category", "DeviceTypeSelect.do?devicecategoryid=" + escape(id("category").value), devicecallback);
>
> }
>
> }
>
> Everything is fine, I can see the select box and all the options are there but when I trigger a onchange event I get the error. Can anyone see what I am doing wrong?
>
>
>
> Thanks.
>
>


Attachment: user_184613.ezm (zipped)

Struts 2 - Java - JSP

For storing user login information in the database, when a user logs in I
need to get the following types of information: Hostname, IP address,
User-Agent, sessionId, etc.
Before using Struts2, I would access the HTTPSession and request object and
use methods such as:
request.getHeader()
request.getHeaderNames()
request.getRemoteAddr()

What is the best practice to access this information using Struts 2 actions?

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_184614.ezm (zipped)
mojoRising wrote:
> Struts 2 - Java - JSP
>
> For storing user login information in the database, when a user logs in I
> need to get the following types of information: Hostname, IP address,
> User-Agent, sessionId, etc.
> Before using Struts2, I would access the HTTPSession and request object and
> use methods such as:
> request.getHeader()
> request.getHeaderNames()
> request.getRemoteAddr()
>
> What is the best practice to access this information using Struts 2 actions?

http://struts.apache.org/2.0.11/docs/how-do-we-get-access-to-the-session.html
http://struts.apache.org/2.0.11/docs/how-can-we-access-the-httpservletrequest.html
http://struts.apache.org/2.0.11/docs/how-can-we-access-the-httpservletresponse.html

L.


Attachment: user_184616.ezm (zipped)
Hi all,

It seems that my struts application's validator does not work. I've add
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
 value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
to my struts-config.xml and these two files surely exist.

Actually, it did work yesterday and I don't remember there are any change applied to my application. But the validator just does not work.

Have you ever met with this situation? Or is there any way to find out the reason why the validator doesn't work? I can debug my application.

Thanks.

Talos

Attachment: user_184617.ezm (zipped)
Finally I found the problem!

I did apply a slight change to the validator.xml yesterday: just added the following xml header.

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1.dtd">

But in the above header, the version of validator is declared as 1.1 while in my validator-rules.xml, the version is 1.0! So, obviously there is a version conflict which caused the validator did not work.

Talos


----- Original Message -----
From: "Chen Chunwei" <out-chenchunwei@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 26, 2008 9:45 AM
Subject: The validator does not work


Hi all,

It seems that my struts application's validator does not work. I've add
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
 value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
to my struts-config.xml and these two files surely exist.

Actually, it did work yesterday and I don't remember there are any change applied to my application. But the validator just does not work.

Have you ever met with this situation? Or is there any way to find out the reason why the validator doesn't work? I can debug my application.

Thanks.

Talos

Attachment: user_184618.ezm (zipped)
The other benefit of the DAO / Manager / Action layers is that you can
use spring to wire up the Manager/Service methods as the transaction
boundaries. Sets of changes you want to all succeed or fail atomically?
Put it in the manager. Managers are where business logic belongs,
DAO's where DB maintenance logic belongs, Actions are just one interface
into this, as you can expose managers as web services, too...

-Dale

Attachment: user_184619.ezm (zipped)

Hi All,
Does someone now the replacement for MessageResourceConfig and
MessageResourceFactory in struts2. And also need a brief description for
using message resources in struts 2.

Thanks in Advance,
Sandeep
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_184620.ezm (zipped)

Hello,

Has anyone tried AjaxAnywhere with Struts 2.1? My action class is never
called. Actually, i am using ajax to achieve pagination in displaytag. I
have used the example from the following link
raibledesigns.com/rd/entry/the_future_of_the_displaytag. But the control
doesnt reach my action class. The links addresses are updated correctly.
After changing the page, following exception is shown in the log file.
"ognl.InappropriateExpressionException: Inappropriate OGNL expression: (d -
6210418) - p" But after that nothing happens. The control comes back to the
jsp without updating or refreshing my table.

It would be very helpful if someone could guide me to achieve my desired
task.

Thanks in advance,

sagauhar
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_184621.ezm (zipped)

Thanks Lukasz



Lukasz Lenart wrote:
>
>> <td><s:password name="pwd" label="Your Password"/></td>
>
> By default s:password tag don't shows value of your password, you can
> change such behaviour by adding attribute showPassword=true, but you
> should consider security issue.
>
>
> Regards
> --
> Lukasz
>
> http://www.linkedin.com/in/lukaszlenart
>
> ---------------------------------------------------------------------
> 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_184622.ezm (zipped)

Hi

Is it possible for me to have multilingual Validations using Annotation
Based Validations in Struts2 ?

Please let me know how I can achieve this .

Thanks,
Tauri.





Tauri Valor wrote:
>
> Thanks Lukasz
>
>
>
> Lukasz Lenart wrote:
>>
>>> <td><s:password name="pwd" label="Your Password"/></td>
>>
>> By default s:password tag don't shows value of your password, you can
>> change such behaviour by adding attribute showPassword=true, but you
>> should consider security issue.
>>
>>
>> Regards
>> --
>> Lukasz
>>
>> http://www.linkedin.com/in/lukaszlenart
>>
>> ---------------------------------------------------------------------
>> 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_184623.ezm (zipped)
> Is it possible for me to have multilingual Validations using Annotation
> Based Validations in Struts2 ?

Yes, you can, just add key = some.error.message to your annotation, like below

  @RequiredStringValidator(key = "some.key")
  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }


Regards
--
Lukasz

http://www.linkedin.com/in/lukaszlenart

Attachment: user_184626.ezm (zipped)

Thanks again.

I tried the following:

In my action:
@RequiredStringValidator(key = "error.message", message = "")
 public String getFirstName() {
   return firstName;
 }


I created the properties file just under my action with the name
"MyActionName.properties" with the following contents:

error.message = ${getText(firstName)} is required.
fieldFormat = ${getText(fieldName)} is not formatted properly.

But I do not the error message as: "error.message" instead of "firstName is
required"

Where am I erring ?

Thanks,
Tauri






Lukasz Lenart wrote:
>
>> Is it possible for me to have multilingual Validations using Annotation
>> Based Validations in Struts2 ?
>
> Yes, you can, just add key = some.error.message to your annotation, like
> below
>
>   @RequiredStringValidator(key = "some.key")
>   public void setFirstName(String firstName) {
>      this.firstName = firstName;
>   }
>
>
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_184628.ezm (zipped)

Thanks again.

I tried the following:

In my action:
@RequiredStringValidator(key = "error.message", message = "")
 public String getFirstName() {
   return firstName;
 }


I created the properties file just under my action with the name
"MyActionName.properties" with the following contents:

error.message = ${getText(firstName)} is required.
fieldFormat = ${getText(fieldName)} is not formatted properly.

But I get the error message as: "error.message" instead of "firstName is
required"

Where am I erring ?

Thanks,
Tauri






Lukasz Lenart wrote:
>
>> Is it possible for me to have multilingual Validations using Annotation
>> Based Validations in Struts2 ?
>
> Yes, you can, just add key = some.error.message to your annotation, like
> below
>
>   @RequiredStringValidator(key = "some.key")
>   public void setFirstName(String firstName) {
>      this.firstName = firstName;
>   }
>
>
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_184632.ezm (zipped)
Hi,

You mess too many thing, please try like this:

@RequiredStringValidator(key = "error.required", message = "Please
enter a value for First name")

error.required = ${fieldName} is required!



Regards
--
Lukasz

http://www.linkedin.com/in/lukaszlenart

Attachment: user_184624.ezm (zipped)
Hi all,

just as title

Thanks.

Talos

Attachment: user_184625.ezm (zipped)
http://struts.apache.org/2.x/docs/client-side-validation.html

Nils-H

On Wed, Mar 26, 2008 at 9:34 AM, Chen Chunwei
<out-chenchunwei@(protected):
> Hi all,
>
> just as title
>
> Thanks.
>
> Talos

Attachment: user_184629.ezm (zipped)
My struts version is 1.1. And I tried to add <html:javascript formName="submitForm" /> in my jsp file which needs validation. But it seems not working.

Talos

----- Original Message -----
From: "Nils-Helge Garli Hegvik" <nilsga@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 26, 2008 4:39 PM
Subject: Re: How to enable the client side validation?


http://struts.apache.org/2.x/docs/client-side-validation.html

Nils-H

On Wed, Mar 26, 2008 at 9:34 AM, Chen Chunwei
<out-chenchunwei@(protected):
> Hi all,
>
> just as title
>
> Thanks.
>
> Talos

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment: user_184630.ezm (zipped)
2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> My struts version is 1.1. And I tried to add <html:javascript
> formName="submitForm" /> in my jsp file which needs validation. But it seems
> not working.



See:
http://struts.apache.org/1.1/userGuide/building_view.html#validator

Antonio

Attachment: user_184633.ezm (zipped)
Thanks Antonio

As I said, I've already used <html:javascript>. Of course, I've alse done the other stuff found in the document you refer to (offline version). But it does not work.

Can you give some more details of using client-side validation?

Talos

----- Original Message -----
From: "Antonio Petrelli" <antonio.petrelli@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 26, 2008 4:56 PM
Subject: Re: How to enable the client side validation?


2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> My struts version is 1.1. And I tried to add <html:javascript
> formName="submitForm" /> in my jsp file which needs validation. But it seems
> not working.



See:
http://struts.apache.org/1.1/userGuide/building_view.html#validator

Antonio

Attachment: user_184634.ezm (zipped)
2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> As I said, I've already used <html:javascript>. Of course, I've alse done
> the other stuff found in the document you refer to (offline version). But it
> does not work.



What exactly does not work? Give more details, for example, exceptions at
startup of the application, or the Javascript code is not generated, etc.

Antonio

Attachment: user_184635.ezm (zipped)
Well, the case is that the Javascript code was generated well, but it was not triggered.

Talos

----- Original Message -----
From: "Antonio Petrelli" <antonio.petrelli@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 26, 2008 5:10 PM
Subject: Re: How to enable the client side validation?


2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> As I said, I've already used <html:javascript>. Of course, I've alse done
> the other stuff found in the document you refer to (offline version). But it
> does not work.



What exactly does not work? Give more details, for example, exceptions at
startup of the application, or the Javascript code is not generated, etc.

Antonio

Attachment: user_184636.ezm (zipped)
2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> Well, the case is that the Javascript code was generated well, but it was
> not triggered.



Well, that's strange. Can you post, the generated HTML and Javascript code?
What browser are you using? Changing browser changes anything?

Antonio

Attachment: user_184637.ezm (zipped)
I found the answer.

There's an attribute in <html:javascript> named method. You can specify a name in this attribute such as validateForm. Then specify the onsubmit event of the actual form with "return validateForm(this);". After all, the javascript works.

The above solution comes from my colleague. But I wonder know is there any document refer to this? Or it should be a common sense?

Talos

----- Original Message -----
From: "Antonio Petrelli" <antonio.petrelli@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 26, 2008 5:18 PM
Subject: Re: How to enable the client side validation?


2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> Well, the case is that the Javascript code was generated well, but it was
> not triggered.



Well, that's strange. Can you post, the generated HTML and Javascript code?
What browser are you using? Changing browser changes anything?

Antonio

Attachment: user_184639.ezm (zipped)
2008/3/26, Chen Chunwei <out-chenchunwei@(protected)>:
>
> There's an attribute in <html:javascript> named method. You can specify a
> name in this attribute such as validateForm. Then specify the onsubmit event
> of the actual form with "return validateForm(this);". After all, the
> javascript works.
>
> The above solution comes from my colleague. But I wonder know is there any
> document refer to this? Or it should be a common sense?



Good catch. In fact, I think that the docs should be fixed, because also in
the draft docs there is no reference about it:
http://struts.apache.org/1.x/userGuide/building_view.html#validator

So feel free to open an issue (and provide a patch, if you can :-) ):
https://issues.apache.org/struts/browse/STR

Antonio

Attachment: user_184627.ezm (zipped)
Hi,

I want to use s:if with a Constant from a java class:

<s:if test="%{kzAuftr == Constants.ORDER_STATUS_EMPTY }">

But this does not work. It works if I use:

<s:if test="%{kzAuftr == 'L' }">

Is there a way to use the constants class?

Best Regards,
Marc

Attachment: user_184638.ezm (zipped)
> <s:if test="%{kzAuftr == Constants.ORDER_STATUS_EMPTY }">

<s:if test="%{#kzAuftr == @full.package.Constants@(protected) }"

and check this link, section Accessing static properties
http://struts.apache.org/2.x/docs/ognl-basics.html


Regards
--
Lukasz

http://www.linkedin.com/in/lukaszlenart

Attachment: user_184631.ezm (zipped)
Hi Dave,

Thanks for your reponse. Anyway, I will try to convince you ;)

Some background: i have a page where a list of products are shown. In that page there is a button to compare products. What the button does is collect all the selected product's id and call an action: CompareProducts.do?productID=111&productID=222 etc. As the product selection is done by the user, the complete url is created with javascript :(. Consequently, the action CompareProducts has an array like that: String[] productID. So, when the action returns the page, i can access the array productID.
What i want to do is to put an button in the comparation page that allows the user to deselect a product. So, i need to call the action CompareProducts with all the ids (productID) removing the product's id that has been deselected.
And i want to do that with s2 tags and not with javascript.

Well, i hope it's a little bit more clear.

Thanks,

Ezequiel.


-----Message d'origine-----
De : Dave Newton [mailto:newton.dave@(protected)]
Envoyé : mardi 25 mars 2008 13:08
À : Struts Users Mailing List
Objet : Re: How to eliminate an entry from an array with s2 tags


--- Ezequiel Puig <e.puig@(protected):
> in my jsp, i have an array of ids and i will like to remove one of
> that ids using s2 tags:
>
> I have tried the following, but it doesn't work :(
> <s:set name="allIDs" value="#parameters.productCode"/>
> <s:set name="newID" value=""/>
> <s:iterator value="#allIDs" status="stat">
>   <s:set name="myID" value="top"/>
>   <s:if test='%{ idToRemove != #myID }'>
>      <s:set name="newID[#stat]" value="#myID"/>
>   </s:if>
> </s:iterator>
>
> Does anyone know how to do it ?

Depending on the underlying collection type you might get an exception. You're not removing anything in the above code anyway, you're replacing a value. You're also using the "status" value like it's an index, but it's not [1].

But why? You'd have to work hard to convince me that the JSP is the place to do something like that.

Dave

[1] http://struts.apache.org/2.0.11.1/struts2-core/apidocs/org/apache/struts2/views/jsp/IteratorStatus.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.