- Timestamp:
- 03/19/12 17:06:58 (12 years ago)
- Location:
- tapas/web
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/project/formTapas.jsp
r406 r419 7 7 <tiles:insert page="/resources/templates/templateEther.jsp" flush="true"> 8 8 9 <tiles:put name="insertCss" type="string"/> 9 <tiles:put name="insertCss" type="string"> 10 <ether:htmlCss cssFile="select"/> 11 </tiles:put> 10 12 <tiles:put name="insertJsOrJsp" type="string"> 11 13 <ether:htmlJs jsFile="library/jquery.json-2.3"/> 14 <ether:htmlJs jsFile="classesForJQuery/Select"/> 12 15 <ether:htmlJsp jspFile="formTapas_script"/> 13 16 </tiles:put> … … 33 36 tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 34 37 35 var interfaceTapas = new InterfaceTapas( );38 var interfaceTapas = new InterfaceTapas(${jSonFileFormats},${jSonYesNos}); 36 39 </script> 37 40 -
tapas/web/project/formTapas_script.jsp
r415 r419 2 2 var InterfaceTapas = Class.create( { 3 3 4 initialize: function( )4 initialize: function(jsonFileFormats,jsonYesNos) 5 5 { 6 6 /** *********** CONTAINERS *********** **/ … … 8 8 this.containerErrors = $( "#errors" ); 9 9 10 this.jsonFileFormats = jsonFileFormats || null; 11 this.jsonYesNos = jsonYesNos || null; 12 10 13 this.containerErrors.hide(); 14 11 15 this.createForm(); 12 16 }, 13 17 18 19 14 20 // CREATES ******************************************************** 21 createTr: function(texte, inputId, container) 22 { 23 var tr=$( document.createElement("tr") ); 24 var td1=$( document.createElement("td") ); 25 var td2=$( document.createElement("td") ); 26 var input=$( document.createElement("input") ); 27 28 29 input.attr({id: inputId}); 30 td1.html(texte); 31 tr.append(td1); 32 td2.append(input); 33 tr.append(td2); 34 container.append(tr); 35 }, 36 37 38 createTrList: function(texte, inputId, container, type) 39 { 40 var tr=$( document.createElement("tr") ); 41 var td1=$( document.createElement("td") ); 42 var td2=$( document.createElement("td") ); 43 var input=$( document.createElement("input") ); 44 45 46 input.attr({id: inputId}); 47 td1.html(texte); 48 tr.append(td1); 49 if (type == 'format') this.displayFileFormats(td2); 50 else if (type == 'yesno') this.displayYesNo(td2); 51 52 tr.append(td2); 53 container.append(tr); 54 }, 55 56 15 57 createForm: function() 16 58 { 17 // Create button elements 18 this.input1 = $( document.createElement( "input" ) ); 19 var input2 = $( document.createElement( "input" ) ); 20 21 this.input1.attr( {id:"1"} ); 22 this.containerForm.append( this.input1 ); 23 24 input2.attr( {id:"2"} ); 25 this.containerForm.append( input2 ); 26 59 60 //Creation div 61 var divPreference=$( document.createElement("div") ); 62 var tabPreference=$( document.createElement("table") ); 63 64 this.createTrList("File format", "p1", tabPreference, 'format'); 65 this.createTr("Rayleigh extinction", "p2", tabPreference); 66 this.createTrList("H20 extinction", "p3", tabPreference, 'yesno'); 67 this.createTrList("O3 extinction", "p4", tabPreference, 'yesno'); 68 this.createTrList("O2 extinction", "p5", tabPreference, 'yesno'); 69 this.createTrList("CO2 extinction", "p6", tabPreference, 'yesno'); 70 71 divPreference.append( tabPreference ); 72 this.containerForm.append( divPreference ); 73 74 //jQuery.proxy permet d'envoyer le contexte this courant 27 75 var submitButton = new Button( {value:tapasTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} ); 28 76 29 77 }, 78 79 30 80 31 81 // REQUESTS ******************************************************** … … 59 109 }, 60 110 111 61 112 // OTHERS ******************************************************** 113 displayFileFormats: function(container) 114 { 115 var paramSelect = new Object(); 116 paramSelect.id = "select_formats"; 117 paramSelect.parent = container; 118 this.selectFormats = new Select( paramSelect ); 119 jQuery.each( this.jsonFileFormats, jQuery.proxy( function ( i, jsonFileFormat ) 120 { 121 this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text ); 122 }, this ) ); 123 this.selectFormats.selectFirst( false ); 124 }, 125 126 127 displayYesNo: function(container,name) 128 { 129 var paramSelect = new Object(); 130 paramSelect.id = "select_"+name; 131 paramSelect.parent = container; 132 this.selectYesNos = new Select( paramSelect ); 133 jQuery.each( this.jsonYesNos, jQuery.proxy( function ( i, jsonYesNo ) 134 { 135 this.selectYesNos.add( jsonYesNo.value, jsonYesNo.text ); 136 }, this ) ); 137 this.selectYesNos.selectFirst( false ); 138 }, 139 140 62 141 showErrors: function( result ) 63 142 { -
tapas/web/src/com/ether/Controller.java
r416 r419 5 5 import com.ether.annotation.ParamName; 6 6 import com.ether.annotation.UseJSON; 7 import com.ether.tapas.Observatory; 7 8 import com.ether.tapas.Tapas; 9 import com.ether.user.UserRole; 8 10 import net.sf.json.JSONObject; 9 11 import org.apache.commons.logging.Log; 10 12 import org.apache.commons.logging.LogFactory; 11 13 14 import java.util.ArrayList; 12 15 import java.util.HashMap; 16 import java.util.List; 13 17 import java.util.Map; 14 18 … … 25 29 /** *********************************************************** **/ 26 30 @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 27 public Map<String, Object>viewForm()31 public JSONObject viewForm() 28 32 throws WebException 29 33 { 30 return new HashMap<String, Object>(); 34 35 try 36 { 37 final List<Observatory> allObservatories = getTapasService().getAllObservatories(); 38 39 final JSONObject jsonObject = new JSONObject(); 40 jsonObject.put( "jSonFileFormats", getJSONFileFormat() ); 41 jsonObject.put( "jSonYesNos", getJSONYesNo() ); 42 jsonObject.put( "jSonObservatories", allObservatories ); 43 return jsonObject; 44 } 45 catch( ServiceException e ) 46 { 47 throw new WebException( WebException.WebCode.ERROR_NO_OBSERVATORY_FOUND, e ); 48 } 49 31 50 } 51 52 53 54 32 55 33 56 /** *********************************************************** **/ … … 49 72 } 50 73 74 private List<JSONObject> getJSONFileFormat() 75 { 76 final FileFormat[] fileFormats = FileFormat.values(); 77 78 final List<JSONObject> jsonFileFormats = new ArrayList<JSONObject>( fileFormats.length ); 79 80 for( final FileFormat fileFormat : fileFormats ) 81 { 82 final JSONObject jsonFileFormat = new JSONObject(); 83 jsonFileFormat .put( "text", fileFormat.name() ); 84 jsonFileFormat .put( "value", fileFormat.name() ); 85 jsonFileFormats.add( jsonFileFormat ); 86 } 87 return jsonFileFormats; 88 } 89 90 private List<JSONObject> getJSONYesNo() 91 { 92 final YesNo[] yesNos = YesNo.values(); 93 94 final List<JSONObject> jsonYesNos = new ArrayList<JSONObject>( yesNos.length ); 95 96 for( final YesNo yesNo : yesNos ) 97 { 98 final JSONObject jsonYesNo = new JSONObject(); 99 jsonYesNo .put( "text", yesNo.name() ); 100 jsonYesNo .put( "value", yesNo.name() ); 101 jsonYesNos.add( jsonYesNo ); 102 } 103 return jsonYesNos; 104 } 105 51 106 private static final Log LOGGER = LogFactory.getLog( Controller.class ); 52 107 -
tapas/web/src/com/ether/WebException.java
r416 r419 44 44 USER_ALREADY_EXISTS, 45 45 ERROR_ENCRYPT_PASSWORD, 46 ERROR_EMAIL_CANNOT_BE_SEND 46 ERROR_EMAIL_CANNOT_BE_SEND, 47 ERROR_NO_OBSERVATORY_FOUND 47 48 } 48 49
Note: See TracChangeset
for help on using the changeset viewer.