Re: If tag expression problem

2010-10-08 Thread Darren Karstens
I tried putting the current page value into the action like you said
and it works!! Still not sure why the other method failed, but its
working now :)
Thanks for the help
Darren


On Fri, Oct 8, 2010 at 11:15 AM, Darren Karstens
 wrote:
> Hi,
> I tried  but still no luck.
>
> Here is the code for generating the pages array inside the action:
>
> private String pages[];
>
> // inside execute...
> pageSize = 15;
> int numberCards = this.retrieveNumberCards(db,(String)user);
> this.pages = new String[(numberCards/this.pageSize)+1];
> for (int i = 0; i<(numberCards/this.pageSize)+1; i++) this.pages[i] =
> Integer.toString(i);
>
> // getter and setters...
> public String[] getPages()
> {
>    return this.pages;
> }
>
> public void setPages(String[] pages)
> {
>    this.pages = pages;
> }
>
> On Fri, Oct 8, 2010 at 10:57 AM, Li Ying  wrote:
>> I think there is a type mismatch too.
>>
>> Converting the array [pages] to strings should work,
>>
>> can you post your code, show us how you convert it?
>>
>> Or, you can try this:
>>
>> 
>>
>> see if it works.
>>
>>
>>
>>
>> 2010/10/8 Darren Karstens :
>>> Hi,
>>> I have the following code that displays a list of page numbers that
>>> all have links except for the current page (defined by the request
>>> parameter 'page'):
>>>
>>> 
>>>  
>>>    
>>>  
>>>  
>>>    
>>>  
>>> 
>>>
>>> However this doesn't work and the if condition is alway false. I tried
>>> outputting the value of #it in each itteration and got the correct
>>> values (numbers 1-5) and done the same with the #parameters['page']
>>> and got the number 2. I also tried substituting the if tag for >> test="#it==2"> and this worked!! The pages array in the action was an
>>> array of ints so I thought maybe there is a type mismatch since the
>>> request parameter would be a string so I tried converting the array to
>>> strings but still no luck. Is this if tag valid? Can anyone tell me
>>> where im going wrong?
>>> Regards,
>>> Darren
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: If tag expression problem

2010-10-08 Thread Darren Karstens
Hi,
I tried  but still no luck.

Here is the code for generating the pages array inside the action:

private String pages[];

// inside execute...
pageSize = 15;
int numberCards = this.retrieveNumberCards(db,(String)user);
this.pages = new String[(numberCards/this.pageSize)+1];
for (int i = 0; i<(numberCards/this.pageSize)+1; i++) this.pages[i] =
Integer.toString(i);

// getter and setters...
public String[] getPages()
{
return this.pages;
}

public void setPages(String[] pages)
{
this.pages = pages;
}

On Fri, Oct 8, 2010 at 10:57 AM, Li Ying  wrote:
> I think there is a type mismatch too.
>
> Converting the array [pages] to strings should work,
>
> can you post your code, show us how you convert it?
>
> Or, you can try this:
>
> 
>
> see if it works.
>
>
>
>
> 2010/10/8 Darren Karstens :
>> Hi,
>> I have the following code that displays a list of page numbers that
>> all have links except for the current page (defined by the request
>> parameter 'page'):
>>
>> 
>>  
>>    
>>  
>>  
>>    
>>  
>> 
>>
>> However this doesn't work and the if condition is alway false. I tried
>> outputting the value of #it in each itteration and got the correct
>> values (numbers 1-5) and done the same with the #parameters['page']
>> and got the number 2. I also tried substituting the if tag for > test="#it==2"> and this worked!! The pages array in the action was an
>> array of ints so I thought maybe there is a type mismatch since the
>> request parameter would be a string so I tried converting the array to
>> strings but still no luck. Is this if tag valid? Can anyone tell me
>> where im going wrong?
>> Regards,
>> Darren
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



If tag expression problem

2010-10-08 Thread Darren Karstens
Hi,
I have the following code that displays a list of page numbers that
all have links except for the current page (defined by the request
parameter 'page'):


  

  
  

  


However this doesn't work and the if condition is alway false. I tried
outputting the value of #it in each itteration and got the correct
values (numbers 1-5) and done the same with the #parameters['page']
and got the number 2. I also tried substituting the if tag for  and this worked!! The pages array in the action was an
array of ints so I thought maybe there is a type mismatch since the
request parameter would be a string so I tried converting the array to
strings but still no luck. Is this if tag valid? Can anyone tell me
where im going wrong?
Regards,
Darren

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Logging not working

2010-10-06 Thread Darren Karstens
The  tag worked, thanks that will come in handy. I would
still like to get errors reporting in the logs, any got any ideas?

On Wed, Oct 6, 2010 at 2:39 PM, Mead Lai  wrote:
> try the tag
> 
> on the page
>
>
> Regards,
> Mead
>
>
> On Wed, Oct 6, 2010 at 9:37 PM, Darren Karstens 
> wrote:
>
>> Hi,
>> I can't seem to get any errors to appear when struts goes wrong
>> (action trying to set/get an attribute that doesn't exist etc). I have
>> the commons-logging-1.1.jar file in my /WEB-INF/lib
>> folder and have the 
>> line in my struts.xml file. Despite this I have never seen an error in
>> my log files. Is there something im missing here? Would the errors
>> appear in the same log as servlet exceptions
>> (/logs/localhost.-xx-xx.log)?
>> Thanks in advanced,
>> Darren
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Logging not working

2010-10-06 Thread Darren Karstens
Hi,
I can't seem to get any errors to appear when struts goes wrong
(action trying to set/get an attribute that doesn't exist etc). I have
the commons-logging-1.1.jar file in my /WEB-INF/lib
folder and have the 
line in my struts.xml file. Despite this I have never seen an error in
my log files. Is there something im missing here? Would the errors
appear in the same log as servlet exceptions
(/logs/localhost.-xx-xx.log)?
Thanks in advanced,
Darren

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Problem with required validator

2010-10-05 Thread Darren Karstens
Thanks for the replies. I figured out what the problem was. My model
in the action class is a member variable called user, so I needed to
change the name of my form fields and validator fields to
user.userName instead of just userName.

2010/10/5 Raymond He :
> You can debug your app,and step in the required validator
> class'validation method. And check whether the value is populated .
> Maybe it'snull .
>
> 2010/10/5, Darren Karstens :
>> Hi,
>> I have a xml validator for my user login action which requires values
>> for both the userName and password fields. However when submit the
>> form with these fields populated I still get the same "Username is
>> required" and "Password is required" messages. Am I right in thinking
>> that the "required" validator is triggered if no value is supplied for
>> the field? If thats the case why would it be triggered when I supply
>> values for those fields?
>>
>> Here is the validation xml file:
>>
>> > "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
>> "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
>> 
>>   
>>   
>>   Username is required.
>>   
>>   
>>   
>>   
>>   Password is required.
>>   
>>   
>> 
>>
>> Regards,
>> Darren
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> --
> 从我的移动设备发送
>
> *Kun He*  (or Raymond He)
> A Java Programmer
> Alibaba inc.
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Problem with required validator

2010-10-05 Thread Darren Karstens
Hi,
I have a xml validator for my user login action which requires values
for both the userName and password fields. However when submit the
form with these fields populated I still get the same "Username is
required" and "Password is required" messages. Am I right in thinking
that the "required" validator is triggered if no value is supplied for
the field? If thats the case why would it be triggered when I supply
values for those fields?

Here is the validation xml file:

http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>

  
  
  Username is required.
  
  
  
  
  Password is required.
  
  


Regards,
Darren

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: How to structure a struts2 application

2010-09-28 Thread Darren Karstens
Thanks for the responses. The validation interceptor seems to be
exactly what I was looking for.
Regards
Darren

> You don't need multiple classes. The validate interceptor, as the prepare
> one, is very flexible in this sense. You can define multiple validate
> methods inside a single action class. Particularly, you could define a
> validate (prepare) method  for every entry point (for instance: update,
> delete, etc.).  You must only follow the convention: use updateValidate for
> validate method update, deleteValidate from delete entry point, and so on.
> Remember that validate/prepare method is always invoked (so you can put here
> common validation rule).
> Furthermore, you can encapsulate validation logic inside an xml file, alway
> following the conventions:
> --validation.xml
>
>
> Maurizio Cucchiara

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



How to structure a struts2 application

2010-09-24 Thread Darren Karstens
Hi,
I have just started learning struts2 and was wondering what is the best way
to structure my application.

I was planning on creating one ActionSupport class to deal with all user
action (creating, editing, login etc). This would have a method for each
type of action (create(), login() etc) and a mapping with a wildcard like
this:


However im not sure if this is the best way of doing things because all of
the user actions would share the same validate method, and each different
type of action would need different validation. I was thinking of maybe
putting a switch in the validate method to do different validation depending
on which action has been called, or perhaps just having different action
classes for each type of user action. Do either of these approaches sound
sensible? Or am I missing an easier way to go about grouping up all the user
actions?
Regards
Darren