Manuel Sanchez Iba�ez

Greenhorn
+ Follow
since Jul 12, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Manuel Sanchez Iba�ez

Thanks very much. In the end, i saw one example in a book and the solution is very easy. In jsp i have used <html:cancel><bean:message key="boton.cancel"/></html:cancel>

In Action class:
public class EjercicioForkAction extends LookupDispatchAction{

protected Map getKeyMethodMap(){
Map map = new HashMap();
map.put("boton.submit","AltaEjercicioAction");
map.put("boton.otroejercicio","AltaRepeatEjercicioAction");
return map;
}

public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
if (isCancelled(request)){
return(mapping.findForward("mainmenu"));
}
return (mapping.findForward("success"));
}

... Other custom actions ...

Regards.
14 years ago
I tried your idea but the form have to validate it previosly. How can i avoid the form validation in this case? Because it�s necesary in submit buttons that all fields are filled (except in cancel button).
14 years ago
Hello and sorry for my english. In my form, i have 2 submit button. I manage the flow using LookupDispatchAction. This works fine and now i want add a cancel button.

If i code this buttons:
<html:submit property="action"><bean:message key="boton.insertarfavoritos"/></html:submit>

<html:submit property="action"><bean:message key="boton.otroejercicio"/></html:submit>

<html:cancel><bean:message key="boton.cancel"/></html:cancel>

throws an error:
Request[/altaejercicioSubmit] does not contain handler parameter named 'action'. This may be caused by whitespace in the label text.

I have created a new class Action for cancel button using LookupDispatchAction:
<html:cancel property="action"><bean:message key="boton.cancel"/></html:cancel>

but then the form validation shows all empty fields.

I have seen the html:cancel documentation:

WARNING - If you set this attribute to a value other than the default, this will NOT be recognized as the cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancel detection.

But i don�t understand. In a normal form with one submit button and one cancel button, in the Action i put:
if (isCancelled(request)){
return(mapping.findForward("mainmenu"));
}


How can i use a html:cancel button using LookupDispatchAction?
14 years ago
Hello, i want validate a integer field but only it�s necessary greaterThan 0. It�s not necessary a maximum. If i write:

<field property="numberpositive" depends="required,integer,intRange">
<arg0 key="campo.numberpositive"/>
<arg1 name="intRange" key="${var:min}" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>0</var-value>
</var>

and throws error, the error shows: It�s not in range between 0 and NULL.

Any solution? I use Struts 1.2.4
14 years ago
Thank you very much for your answer.
14 years ago
Hello, i have a form with a CheckBox field (Cancel) and some fields. I�d like when checkbox is active doesn�t validate other fields but if checkbox isn�t active, other fields must be validate.



One example is the time field. I need time is greater than 0. So, i write:

<var-value>((controles[].anular != true) and (*this* > 0))</var-value>

but if checkbox is active and time is < 0 show the error.

Other example is a address field. It�s required a value in this field except when the checkbox is active. If i write: depends="validwhen,required" then always validate it.

Is it possible this situation validating with Struts?

Sorry for my english, regards.
14 years ago
Hello all, you are the last hope. Sorry for my english, i speak english a litle. I have a form with a unknown number of fields and something fields have multiple possibility.

I use Struts and i have resolved the problem of unknown fields using "indexed" property. One example:



The number of fields depends of information loading in DB. Well, one example is this form with 2 records loaded. The fields are initialized with the stored values and the user can modify that values. I put directly the html code generated:




If two records were stored with radio-button value="CONINDATA", each radio-button (value="CONINDATA") of record will appear selected. That�s all right. We suppose two records have selected a radio button with value="conindata".

The problem is when user want to change to other radio button. If he clicks in other radio button (value="GESINDATA") of record1, works fine but if he clicks too in radio button with value="GESINDATA" of record2 throws an error:

"the object don�t accept this property or method"


The JavaScript function change the list of values in select field depending of radio button is clicked (The lists of values are loading in variables)



I think the problem is in bold line because the change of values in select field work fine while the user doesn�t click the same two radio buttons.


If you need more information about my problem, tell me and i will write soon.

Regards.
<html:text property="�lasttName?" size="16" maxlength="16"/>
14 years ago
Hello, i just have the same problem with Struts. Thanks of this post, i have found one solution but now i have a new problem.

I have a Form with one <html:select> and severals fields <html:radio> associated. When i click in one radio field, the list of values change in a select field (others values).

Contenido : <html:select property="contenido" size="1"></html:select>

<html:radio property="tipocontenido" value="conindata" onclic="changeContenidosEjercicio(this.value);"/>Conducta

<html:radio property="tipocontenido" value="gesindata" onclic="changeContenidosEjercicio(this.value);"/>Gesto

I can realize this operation fine with this javascript function (Previosly i have loaded in various arrays (Arrayconindata,Arraygesindata) the diferent values:
------------------------------------------------------
function changeContenidosEjercicio(control){
contenidosArray = new Array();
contenidosEjercicio = document.forms['ejercicioForm'].contenido;
contenidosEjercicio.options.length=0;

if (control == 'conindata') {contenidosArray = Arrayconindata;}
if (control == 'gesindata') {contenidosArray = Arraygesindata;}

for (i=0; i < contenidosArray.length;i++)
contenidosEjercicio.options[i] = contenidosArray[i];
}
-------------------------------------------------------------


Now, i have to recover several beans and show it in a jsp with their values stored. For realize this, i have used indexed="true" in a fields and the javascript function have been modified a litle (adding a index):

<logic:iterate id="controles" name="listaejercicios" indexId="contador">

Contenido : <html:select name="controles" property="contenido" indexed="true" size="1"></html:select>

<html:radio name="controles" property="tipocontenido" value="conindata" indexed="true" onclic="changeContenidosControl(this.value,this.name);"/>Conducta

<html:radio name="controles" property="tipocontenido" value="gesindata" indexed="true" onclic="changeContenidosControl(this.value,this.name);"/>Gesto I
.....


----------------------------------
function changeContenidosControl(control,name){
var contenidosArray = new Array();
var ind = name.substring( name.indexOf('[') +1 ,name.lastIndexOf(']') );
var id = parseInt(ind,10);

var contenidosControl = document.forms['controldinamicoForm'].elements["controles["+ id +"].contenido"];
contenidosControl.options.length = 0;

if (control == 'conindata') {contenidosArray = Arrayconindata;}
if (control == 'gesindata') {contenidosArray = Arraygesindata;}

for (i=0; i < contenidosArray.length;i++)
contenidosControl.options[i] = contenidosArray[i];

}


If i show various records (beans) in a jsp, if i only ckecked one radio button works fine, but if i ckecked the same radio button of other record (bean) throws an error: "the object don�t accept this property or method"

Sorry for my english. Any idea?
Hello, i have two problems with javascript. It�s possible my problem should be placed in other forum but i think only people use Struts can understand me. Sorry for my english, i will try explain my problem:

I have a Form with one <html:select> and severals fields <html:radio> associated. When i click in one radio field, the list of values change in a select field (others values).

Contenido : <html:select property="contenido" size="1"></html:select>

<html:radio property="tipocontenido" value="conindata" onclic="changeContenidosEjercicio(this.value);"/>Conducta

<html:radio property="tipocontenido" value="gesindata" onclic="changeContenidosEjercicio(this.value);"/>Gesto

I can realize this operation fine with this javascript function (Previosly i have loaded in various arrays (Arrayconindata,Arraygesindata) the diferent values:
------------------------------------------------------
function changeContenidosEjercicio(control){
contenidosArray = new Array();
contenidosEjercicio = document.forms['ejercicioForm'].contenido;
contenidosEjercicio.options.length=0;

if (control == 'conindata') {contenidosArray = Arrayconindata;}
if (control == 'gesindata') {contenidosArray = Arraygesindata;}

for (i=0; i < contenidosArray.length;i++)
contenidosEjercicio.options[i] = contenidosArray[i];
}
-------------------------------------------------------------


Now, i have to recover several beans and show it in a jsp with their values stored. For realize this, i have used indexed="true" in a fields and the javascript function have been modified a litle (add a index):

<logic:iterate id="controles" name="listaejercicios" indexId="contador">

Contenido : <html:select name="controles" property="contenido" indexed="true" size="1"></html:select>

One problem: I need pass the index to javascript function. I can put:

<bean efine id="INDX" name="contador"/>

but i can�t put: <%= INDX %>

<html:radio name="controles" property="tipocontenido" value="conindata" indexed="true" onclic="changeContenidosControl(this.value, <%= INDX %> );"/>Conducta



Well, we suppose the index value is passed good. This code generate the out:

Contenido : <select name="controles[0].contenido" size="1"></select>
<input type="radio" name="controles[0].tipocontenido" value="conindata" checked="checked" onclic="changeContenidosControl(this.value,0);">Conducta

<input type="radio" name="controles[0].tipocontenido" value="gesindata" onclic="changeContenidosControl(this.value,0);">Gesto
...........................

Contenido : <select name="controles[1].contenido" size="1"></select>
<input type="radio" name="controles[1].tipocontenido" value="conindata" checked="checked" onclic="changeContenidosControl(this.value,1);">Conducta

<input type="radio" name="controles[1].tipocontenido" value="gesindata" onclic="changeContenidosControl(this.value,1);">Gesto



Second problem: How do i declare the javascript function using a dinamic form?

function changeContenidosControl(control,i){
contenidosControl =

document.forms['controles'][i].contenido ??
document.forms['controldinamicoForm'][i].contenido ??
document.forms['controldinamicoForm'].controles[i].contenido ??
document.forms['controldinamicoForm'.controles[i]].contenido ??
document.forms[i].elements["controles["+ i +"].contenido"]; ??
...

Regards.
14 years ago
I continue with my problem. I have readed about DynaActionForm and DynaValidatorForm. I think my problem will be resolved with this option but my tests don�t work.

I hope explain clearly (my english is bad). I want show in a jsp form a unknown numbers of Objects:

Pre-Action:


In a Jsp page:



My jsp page shows a good information:
<input type="text" name="controles[0].tiempoteorico" value="25">
<input type="text" name="controles[1].tiempoteorico" value="30">
....

According to information, i declare this in struts-config.xml:





So, the user can update/modify that values and when it submitted the form, i want recover all values.


My Action:


This Action cause an error:
excepci�n
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:497)
....

causa ra�z
java.lang.ArrayIndexOutOfBoundsException
java.lang.reflect.Array.get(Native Method)
org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:252)
org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:386)
....


Any idea will be grateful.
14 years ago
Hello, i have searched this question in Search utility but i didn�t found the solution. In a jsp page, i have a variable form. Sorry for my english. Part of code is:

----Action that recover information for modify in a jsp page----

session.setAttribute("listaejercicios",listacontrol);




----Jsp Page----

<html:form action="altacontrolSubmit.do?method=AltaControlEjerciciosAction">

<logic:iterate id="datos" name="listaejercicios">
<html:text name="datos" property="tiempoteorico" indexed="true"/>
....


The jsp page work fine and each property shows it value. One example is two exercises like:

<input type="text" name="datos[0].tiempoteorico" value="25">
<input type="text" name="datos[1].tiempoteorico" value="30">


I don�t know how many exercises there is so my form is:

---MyForm---

public class ListaControlForm extends ValidatorForm{

private ControlForm[] listacontrol;

public ListaControlForm(){
listacontrol = new ControlForm[0];
}

public void setListacontrol(ControlForm[] listacontrol){
this.listacontrol = listacontrol;
}

public void setListacontrol(int index,ControlForm listacontrol){
this.listacontrol[index] = listacontrol;
}

public ControlForm[] getListacontrol(){
return listacontrol;
}

public ControlForm getListacontrol(int index){
return listacontrol[index];
}

public void reset(ActionMapping mapping, HttpServletRequest request){
this.listacontrol = new ControlForm[0];
}



public class ControlForm{

private String tiempoteorico;

public ControlForm(){
tiempoteorico = null;
}

public void setTiempoteorico(String tiempoteorico){
this.tiempoteorico = tiempoteorico;
}

public String getTiempoteorico(){
return tiempoteorico;
}
}
}




I�d like in Action recover all values for storing in DB but i don�t know this issue.

---My Action---

ListaControlForm listacontrol = (ListaControlForm) form;

for (int i=0; i<listacontrol.length(); i++){
//shows an error :length cannot be resolved or is not a field
}


I think this error is due to i have to create one method in ListaControlForm like as:

public int Longitudlistacontrol(){
return listacontrol.length;
}

but if i put in Action:
ListaControlForm listacontrol = (ListaControlForm) form;
int tamano = listacontrol.getLongitudlistacontrol();

shows an error again.

Anyone can help me? or any idea?
14 years ago
too i�m interesting in this issue. What size is greater? saving in a folder/File or saving in Blob field?

The option more good is other issue. I�m interesting in the size

�Anyone can help me?
Hello, i have a similar problem. I use a session object for display information in ArrayList. Each element in ArrayList is a class like:

private String nombre;
private int tiempofila;


I need divide one number between "tiempofila" but i only can show this value. I can recover and show this value in 3 ways:

<logic resent name="tabladatos">

<logic:iterate id="inf2" name="tabladatos">

<bean efine id="por2" name="inf2" property="tiempofila"/>
<bean:write name="por2"/>%<br/>

<jsp:getProperty name="inf2" property="tiempofila"/>%<br/>

<bean:write name="inf2" property="tiempofila"/>%<br/>

---<br/>
</logic:iterate>
......

This code work fine but i don�t need show this value, i need work with it:

<%int value = <bean:write name="inf2" property="tiempofila"/> %>

My goal is calculate one percentaje:

<%int percentaje = 33 * 100 / value %>

�Is possible assign this?
15 years ago
I don�t understand your idea. Finally, i have written other validation in validation-rules.xml and i can verify well that 3 fields aren�t null.

Thanks for your interest.
15 years ago