IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

h:selectOneMenu selected value


Sujet :

JSF Java

  1. #1
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Points : 2 336
    Points
    2 336
    Par défaut h:selectOneMenu selected value
    Salut

    J ai encore un petit soucies avec mes h:selectOneMenu et la récupération de valeures contenu dans une page jsf

    dans ma page jsf j ai le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
     
    ...
    		<h:panelGrid rendered="true" id="pnlProductType" columns="2">
    			<h:outputText id="lblIdentification" value="#{text.common_identification}" styleClass="text_title" />
    			<h:outputText id="lblIdentification2" value="" styleClass="text_title" />
    			<h:outputText id="lblMarket" value="#{text.common_marketCode}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectMarket" value="#{productGui.marketId}" onchange="submit();" valueChangeListener="#{productGui.change}"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{marketGui.markets}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblProductCode" value="#{text.common_productCode}" styleClass="text_subtitle" />					
    			<h:inputText id="txtProductCode"></h:inputText>
    			<h:outputText id="lblBrand" value="#{text.common_brand}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectBrand" value="#{productGui.brand"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{brandGui.brands}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblDescription" value="#{text.common_description}" styleClass="text_subtitle" />					
    			<h:inputText id="txtDescription"></h:inputText>
    			<h:outputText id="lblModel" value="#{text.common_model}" styleClass="text_subtitle" />					
    			<h:inputText id="txtModel"></h:inputText>
    			<h:outputText id="lblVersion" value="#{text.common_version}" styleClass="text_subtitle" />					
    			<h:inputText id="txtVersion"></h:inputText>
    			<h:outputText id="lblSerial" value="#{text.common_serial}" styleClass="text_subtitle" />					
    			<h:inputText id="txtSerial"></h:inputText>
    			<h:outputText id="lblChassis" value="#{text.common_chassisCode}" styleClass="text_subtitle" />					
    			<h:inputText id="txtChassis"></h:inputText>
    			<h:outputText id="lblAssignationDate" value="#{text.common_assignationDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtAssignationDate"></h:inputText>
    			<h:outputText id="lblTitleInformationAcquisition" value="#{text.common_informationProductAcquisition}" styleClass="text_title" />
    			<h:outputText id="lblTitleInformationAcquisition2" value="" styleClass="text_title" />
    			<h:outputText id="lblPurchaseDealer" value="#{text.common_purchaseDealer}" styleClass="text_subtitle" />					
    			<h:inputText id="txtPurchaseDealer"></h:inputText>
    			<h:outputText id="lblOrderNumber" value="#{text.common_orderNumber}" styleClass="text_subtitle" />					
    			<h:inputText id="txtOrderNumber"></h:inputText>
    			<h:outputText id="lblOrderDate" value="#{text.common_orderDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtOrderDate"></h:inputText>
    			<h:outputText id="lblDeliveryForecastDate" value="#{text.common_deliveryForecastDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtDeliveryForecastDate"></h:inputText>
    			<h:outputText id="lblMovementDate" value="#{text.common_movementDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtMovementDate"></h:inputText>
    			<h:outputText id="lblShippingDate" value="#{text.common_shippingDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtShippingtDate"></h:inputText>
    			<h:outputText id="lblDeliveryDate" value="#{text.common_deliveryDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtDeliverytDate"></h:inputText>
    			<h:outputText id="lblInitialSaleTypeDate" value="#{text.common_initialSaleTypeDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtInitialSaleTypeDate"></h:inputText>
    			<h:outputText id="lblRequestPlateDate" value="#{text.common_requesPlateDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtRequestPlateDate"></h:inputText>
    			<h:outputText id="lblTitleInvoicingInformation" value="#{text.common_invoicingInformation}" styleClass="text_title" />
    			<h:outputText id="lblTitleInvoicingInformation2" value="" styleClass="text_title" />
    			<h:outputText id="lblInvoiceNumber" value="#{text.common_invoiceNumber}" styleClass="text_subtitle" />					
    			<h:inputText id="txtInvoiceNumber"></h:inputText>			
    			<h:outputText id="lblInvoiceDate" value="#{text.common_invoiceDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtInvoiceDate"></h:inputText>						
    			<h:outputText id="lblCurrency" value="#{text.currencyTitle}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectCurrency" value="#{productGui.currency"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{currencyGui.currenciesItem}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblGrossAmount" value="#{text.common_grossAmount}" styleClass="text_subtitle" />					
    			<h:inputText id="txtGrossAmount"></h:inputText>						
    			<h:outputText id="lblBasisAmount" value="#{text.common_basisAmount}" styleClass="text_subtitle" />					
    			<h:inputText id="txtBasisAmount"></h:inputText>						
    			<h:outputText id="lblNetAmount" value="#{text.common_netAmount}" styleClass="text_subtitle" />					
    			<h:inputText id="txtNetAmount"></h:inputText>						
    			<h:outputText id="lblPayementNoticeDate" value="#{text.common_payementNoticeDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtPayementNoticeDate"></h:inputText>						
    			<h:outputText id="lblPayementDate" value="#{text.common_payementDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtPayementDate"></h:inputText>						
    			<h:outputText id="lblTitleProductSaleInformation" value="#{text.common_productSaleInformation}" styleClass="text_title" />
    			<h:outputText id="lblTitleProductSaleInformation2" value="" styleClass="text_title" />
    			<h:outputText id="lblSaleDealer" value="#{text.common_saleDealer}" styleClass="text_subtitle" />					
    			<h:inputText id="txtSaleDealer"></h:inputText>						
    			<h:outputText id="lblSaleDate" value="#{text.common_saleDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtSaleDater"></h:inputText>						
    			<h:outputText id="lblRefSaleType" value="#{text.common_refSaleType}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectSaleType" value="#{productGui.saleType}" immediate="false"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{saleTypeGui.saleTypeItems}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblRegistrationDate" value="#{text.common_registrationDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtRegistrationDate"></h:inputText>						
    			<h:outputText id="lblApprovalNumber" value="#{text.common_approvalNumber}" styleClass="text_subtitle" />					
    			<h:inputText id="txtApprovalNumber"></h:inputText>						
    			<h:outputText id="lblContractDate" value="#{text.common_contractDate}" styleClass="text_subtitle" />					
    			<h:inputText id="txtContractDate"></h:inputText>						
    			<h:outputText id="lblCustomerType" value="#{text.common_customerType}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectCustomerType" value="#{productGui.customerType}"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{customerTypeGui.customerTypes}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblTitleManagementInformation" value="#{text.common_managementInformation}" styleClass="text_title" />
    			<h:outputText id="lblTitleManagementInformation2" value="" styleClass="text_title" />
    			<h:outputText id="lblRefBudgetFamily" value="#{text.common_refBudgetFamily}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectBudgetFamily" value="#{productGui.budgetFamily}"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{budgetFamilyGui.budgetFamilys}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblRefInsideColor" value="#{text.common_refInsideColor}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectInsideColor" value="#{productGui.intColor}"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{intColorGui.intColors}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblRefOutsideColor" value="#{text.common_refOutsideColor}" styleClass="text_subtitle" />					
    			<h:selectOneMenu id="selectOutsideColor" value="#{productGui.outColor}"> 
    				<f:selectItem itemValue=""/>
    				<f:selectItems value="#{outColorGui.outColors}" />
    			</h:selectOneMenu> 
    			<h:outputText id="lblNationalOptional" value="#{text.common_nationalOptional}" styleClass="text_subtitle" />					
    			<h:inputText id="txtNationalOptional"></h:inputText>						
    			<h:outputText id="lblSpecialSerial" value="#{text.common_specialSerial}" styleClass="text_subtitle" />					
    			<h:inputText id="txtSpecialSerial"></h:inputText>						
    			<h:outputText id="lblDeliveryCustomerCode" value="#{text.common_deliveryCustomerCode}" styleClass="text_subtitle" />					
    			<h:inputText id="txtDeliveryCustomerCode"></h:inputText>						
    			<h:outputText id="lblDeliveryCustomerCode2" value="" styleClass="text_subtitle" />					
    <%-- Description part (with message table) --%>
    			<h:outputText id="lblDescription" value="#{text.common_description}" styleClass="text_subtitle" />
    			<h:panelGroup>
    	<%-- Choose desc --%>				
    ....
    </custom:layout>
    Puis dans mon managed bean :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
     
    package com.mtsa.ebonus.core.gui.product;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.faces.component.html.HtmlDataTable;
    import javax.faces.component.html.HtmlInputText;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
     
    import com.mtsa.common.control.ErrorController;
    import com.mtsa.common.error.ErrorLevel;
    import com.mtsa.ebonus.core.business.CurrencyService;
    import com.mtsa.ebonus.core.business.LanguageServiceImpl;
    import com.mtsa.ebonus.core.business.product.*;
    import com.mtsa.ebonus.core.gui.UtilGui;
     
    public class ProductGui {
    	/* Error, logs */
    	private static ErrorController ec = ErrorController.getErrorController(ProductGui.class.getName(), ErrorLevel.DEBUG);
    	private static final String ERR_SERVICE_IS_NULL = "GUI2010";
    	private static final String ERR_GET_ENTITIES = "GUI2020";
    	private static final String ERR_SEARCH = "GUI2030";
    	private static final String ERR_DETAIL = "GUI2040";
    	private static final String ERR_CREATE = "GUI2050";
    	private static final String ERR_SAVE = "GUI2060";
    	private static final String ERR_DELETE = "GUI2070";
    	private static final String ERR_DELETE_LIST = "GUI2080";
     
    	private String brand;
    	private String currency;
    	private String saleType;
    	private String customerType;
    	private String budgetFamily;
    	private String intColor;
    	private String outColor;	
    	private String marketId;
     
    	/* Services */
    	private ProductService productService;
    	private CurrencyService currencyService;
    	private CustomerTypeService customerTypeService;
    	private BudgetFamilyService budgetFamilyService;
    	private IntColorService intColorService;
    	private OutColorService outColorService;
    	private SaleTypeService saleTypeService;
    	private BrandService brandService;
    	/* Business Objects */
    	private List<Product> dataList;
    	private Product selectedData;
     
    	/* General attribute */
    	private String txtSearch;
    	private int txtDataTableSize;
    	private int txtResultSetSize;
    	private int txtResultSetPosition;
    	private HtmlInputText txtId = new HtmlInputText();
    	private String lblShowHide;
    	private boolean isMutliLanguageDisplay = false;
    	//Does have we to hide a field text ?
    	private boolean disabled;
     
    	/* Binding */
    	// private javax.faces.component.html.HtmlDataTable jsfDataList = new
    	// javax.faces.component.html.HtmlDataTable(); // for Core
    	private org.apache.myfaces.component.html.ext.HtmlDataTable jsfDataList = new org.apache.myfaces.component.html.ext.HtmlDataTable();
    	private HtmlInputText jsfDescription = new HtmlInputText();
    	private HtmlDataTable jsfMessageList = new HtmlDataTable();
     
    	// Navigation rules
    	private final String GO_LIST = "goProductList";
    	private final String GO_DETAIL = "goProductDetail";
    	private final String GO_ERROR = "goError";
     
    	// TODO initialize with project constants
    	private String CURRENT_USER = "alja";
    	private String FROM = "ProductGui";
     
    	public BrandService getBrandService() {
    		return brandService;
    	}
     
    	public void setBrandService(BrandService brandService) {
    		this.brandService = brandService;
    	}
     
    	public BudgetFamilyService getBudgetFamilyService() {
    		return budgetFamilyService;
    	}
     
    	public void setBudgetFamilyService(BudgetFamilyService budgetFamilyService) {
    		this.budgetFamilyService = budgetFamilyService;
    	}
     
    	public CurrencyService getCurrencyService() {
    		return currencyService;
    	}
     
    	public void setCurrencyService(CurrencyService currencyService) {
    		this.currencyService = currencyService;
    	}
     
    	public CustomerTypeService getCustomerTypeService() {
    		return customerTypeService;
    	}
     
    	public void setCustomerTypeService(CustomerTypeService customerTypeService) {
    		this.customerTypeService = customerTypeService;
    	}
     
    	public IntColorService getIntColorService() {
    		return intColorService;
    	}
     
    	public void setIntColorService(IntColorService intColorService) {
    		this.intColorService = intColorService;
    	}
     
    	public OutColorService getOutColorService() {
    		return outColorService;
    	}
     
    	public void setOutColorService(OutColorService outColorService) {
    		this.outColorService = outColorService;
    	}
     
    	public SaleTypeService getSaleTypeService() {
    		return saleTypeService;
    	}
     
    	public void setSaleTypeService(SaleTypeService saleTypeService) {
    		this.saleTypeService = saleTypeService;
    	}
     
    	public String getBudgetFamily() {
    		return budgetFamily;
    	}
     
    	public void setBudgetFamily(String budgetFamily) {
    		this.selectedData.setBudgetFamily(budgetFamily, this.getMarketId(), budgetFamilyService);
    		this.budgetFamily = budgetFamily;
    	}
     
    	public String getCurrency() {
    		return currency;
    	}
     
    	public void setCurrency(String currency) {
    		this.selectedData.setCurrency(currency, currencyService);
    		this.currency = currency;
    	}
     
    	public String getCustomerType() {
    		return customerType;
    	}
     
    	public void setCustomerType(String customerType) {
    		this.selectedData.setCustomerType(customerType, this.getMarketId(), customerTypeService);
    		this.customerType = customerType;
    	}
     
    	public String getIntColor() {
    		return intColor;
    	}
     
    	public void setIntColor(String intColor) {
    		this.selectedData.setIntColor(intColor, this.getMarketId(), intColorService);		
    		this.intColor = intColor;
    	}
     
    	public String getOutColor() {
    		return outColor;
    	}
     
    	public void setOutColor(String outColor) {
    		this.selectedData.setOutColor(outColor, this.getMarketId(), outColorService);
    		this.outColor = outColor;
    	}
     
    	public String getSaleType() {
    		return saleType;
    	}
     
    	public void setSaleType(String saleType) {
    		this.selectedData.setSaleType(saleType, this.getMarketId(), saleTypeService);
    		this.saleType = saleType;
    	}
     
    	public String getBrand() {
    		return brand;
     
    	}
     
    	public void setBrand(String brand) {
    		this.selectedData.setBrand(brand, this.getMarketId(), brandService);
    		this.brand = brand;
    	}
     
    	public String getMarketId() {
    		return marketId;
    	}
     
    	public void setMarketId(String marketId) {
    		//this.selectedData.setMarketId(marketId);
    		this.marketId = marketId;
     
    	}
     
    	// ------------------- CONSTRUCTOR(S) -----------------------------//
    	// This part is used to initialized some value, at the first page load.
    	public ProductGui() {
    		// ATTENTION !! Here is "productService" always NULL (due to Spring) !!
     
    		// init variables
    		// TODO initialize with user constants
    		txtDataTableSize = 10;
    		txtResultSetSize = 55;
    		marketId = "3104";
    		txtResultSetPosition = 0;
    		lblShowHide = UtilGui.getTranslationText("common_multiLanguage");
    		isMutliLanguageDisplay = false;
     
    	}
     
    	// ----------- CLASS ATTRIBUTES GETTER and SETTER -----------------//
    	public ProductService getProductService() {
    		return this.productService;
    	}
     
    	public void setProduct(ProductService productService) {
    		this.productService = productService;
    	}
     
    	public int getTxtResultSetPosition() {
    		return this.txtResultSetPosition;
    	}
     
    	public void setTxtResultSetPosition(int txtResultSetPosition) {
    		this.txtResultSetPosition = txtResultSetPosition;
    	}
     
    	public int getTxtResultSetSize() {
    		return this.txtResultSetSize;
    	}
     
    	public void setTxtResultSetSize(int txtResultSetSize) {
    		this.txtResultSetSize = txtResultSetSize;
    	}
     
    	public int getTxtDataTableSize() {
    		return this.txtDataTableSize;
    	}
     
    	public void setTxtDataTableSize(int txtDataTableSize) {
    		this.txtDataTableSize = txtDataTableSize;
    	}
     
    	public String getTxtSearch() {
    		return this.txtSearch;
    	}
     
    	public void setTxtSearch(String txtSearch) {
    		this.txtSearch = txtSearch;
    	}
     
    	public String getLblShowHide() {
    		return this.lblShowHide;
    	}
     
    	public void setLblShowHide(String lblShowHide) {
    		this.lblShowHide = lblShowHide;
    	}
     
    	/* Data specific */
    	public List<Product> getDataList() {
    		ec.log("Begin - getDataList()");
    		if (this.txtSearch == null || this.txtSearch.length() == 0) {
    			try {
    				this.dataList = productService.getProducts(marketId, this.txtResultSetPosition, this.txtResultSetSize);
    				ec.log("getDataList(), dataList size: " + dataList.size());
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_GET_ENTITIES, ex);
    				UtilGui.setJSFErrorMessage("getDataList");
    			}
    		}else {
    			this.dataList = productService.getProducts(marketId,this.txtSearch, this.txtResultSetPosition, this.txtResultSetSize);
    		}
    		//		}
    		ec.log("End - getDataList()");
    		return this.dataList;
    	}
     
    	public void setDataList(List<Product> dataList) {
    		ec.log("Begin - setDataList()");
    		this.dataList = dataList;
    		ec.log("End - setDataList()");
    	}
     
    	public Product getSelectedData() {
    		return this.selectedData;
    	}
     
    	public void setSelectedData(Product selectedData) {
    		this.selectedData = selectedData;
    	}
     
    	// ------------------- BINDING -----------------------------//
    	public HtmlDataTable getJsfDataList() {
    		return this.jsfDataList;
    	}
     
    	public void setJsfDataList(org.apache.myfaces.component.html.ext.HtmlDataTable jsfDataList) {
    		this.jsfDataList = jsfDataList;
    	}
     
    	public HtmlInputText getJsfDescription() {
    		return this.jsfDescription;
    	}
     
    	public void setJsfDescription(HtmlInputText jsfDescription) {
    		this.jsfDescription = jsfDescription;
    	}
     
    	public HtmlDataTable getJsfMessageList() {
    		return this.jsfMessageList;
    	}
     
    	public void setJsfMessageList(HtmlDataTable jsfMessageList) {
    		this.jsfMessageList = jsfMessageList;
    	}
     
    	// ------------------- OPERATIONS -----------------------------//
    	/**
             * Use binding on "txtSearch" for searching entities that have "txtSearch"
             * for part of his description
             * 
             * @return action used by JSF (go...) => GO_LIST
             */
    	public String search() {
    		ec.log("Begin - search(), txtSearch:" + txtSearch);
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				if (txtSearch != null && txtSearch.trim().length() > 0) {
    					txtSearch = txtSearch.trim();
    					this.dataList = productService.getProducts(marketId,txtSearch, this.txtResultSetPosition,
    							this.txtResultSetSize);
    				} else {
    					this.dataList = productService.getProducts(marketId,this.txtResultSetPosition,
    							this.txtResultSetSize);
    				}
    				ec.log("End - search(), dataList size: " + dataList.size());
    				return GO_LIST;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_SEARCH, ex);
    				UtilGui.setJSFErrorMessage("error_search", ex);
    				return GO_LIST;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	/**
             * 
             * Diplay details of entity actually in "selectedData"
             * 
             * @return action used by JSF (go...) => GO_DETAIL
             */
    	public String detail() {
    		ec.log("Begin - detail()");
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				String brandId = UtilGui.retrieveStringFromContext("brandId");
    				String marketId = UtilGui.retrieveStringFromContext("marketId");
    				ec.log("detail(), selectedProductId:" + brandId + " selected marketId " + marketId);
    				selectedData = productService.getProduct(brandId, marketId);
    				ec.log("End - detail(), selectedData:" + selectedData);
    				txtId.setDisabled(true);
    				this.setDisabled(true);
    				return GO_DETAIL;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_DETAIL, ex);
    				UtilGui.setJSFErrorMessage("error_detail", ex);
    				return GO_LIST;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	/**
             * 
             * Create a new entity and set it as "selectedData"
             * 
             * @return action used by JSF (go...) => GO_DETAIL
             */
    	public String create() {
    		ec.log("Begin - create()");
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				selectedData = productService.getNewProduct();
    				dataList.add(selectedData);
    				selectedData.trace(CURRENT_USER, FROM);
    				txtId.setDisabled(false);
    				this.setDisabled(false);
    				ec.log("End - create(), selectedData:" + selectedData);
    				return GO_DETAIL;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_CREATE, ex);
    				UtilGui.setJSFErrorMessage("error_create", ex);
    				return GO_LIST;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	/**
             * 
             * Save entity actually in "selectedData"
             * 
             * @return action used by JSF (go...) => GO_LIST
             */
    	public String save() {
    		ec.log("Begin - save(), selectedData:" + selectedData);
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				productService.saveProduct(selectedData, CURRENT_USER, FROM);
    				this.updateSelectedFromDataList();
    				ec.log("End - save()");
    				return GO_LIST;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_SAVE, ex);
    				UtilGui.setJSFErrorMessage("error_save", ex);
    				return GO_DETAIL;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	private void updateSelectedFromDataList() {
    		ec.log("Begin - updateSelectedFromDataList(), dataList size: " + dataList.size());
    		for (int i = 0; i < dataList.size(); i++) {
    			Product brand = dataList.get(i);
    			if (brand.equals(selectedData))
    				dataList.set(i, selectedData);
    		}
    		ec.log("End - updateSelectedFromDataList(), dataList size: " + dataList.size());
    	}
     
    	/**
             * 
             * Delete entity actually in "selectedData"
             * 
             * @return action used by JSF (go...) => GO_LIST
             */
    	public String delete() {
    		ec.log("Begin - delete(), selectedData:" + selectedData);
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				if (selectedData == null) {
    					String brandId = UtilGui.retrieveStringFromContext("brandId");
    					String marketId = UtilGui.retrieveStringFromContext("marketId");
    					selectedData = productService.getProduct(brandId, marketId);
    					ec.log("delete(), selectedData:" + selectedData);
    				}
    				productService.deleteProduct(selectedData, CURRENT_USER, FROM);
    				this.deleteSelectedFromDataList();
    				selectedData = null;
    				ec.log("End - delete()");
    				return GO_LIST;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_DELETE, ex);
    				UtilGui.setJSFErrorMessage("error_delete", ex);
    				return GO_DETAIL;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	/**
             * 
             * Delete entities with "isSelected" (BU attribute) to true
             * 
             * @return action used by JSF (go...) => GO_LIST
             */
    	public String deleteList() {
    		ec.log("Begin - deleteList()");
    		if (productService == null) {
    			ec.handleError(ERR_SERVICE_IS_NULL);
    		} else {
    			try {
    				for (int i = 0; i < dataList.size(); i++) {
    					selectedData = dataList.get(i);
    					if (selectedData.getIsSelected()) {
    						productService.deleteProduct(selectedData, CURRENT_USER, FROM);
    						this.deleteSelectedFromDataList();
    						ec.log("deleteList(), selectedData to delete:" + selectedData);
    					}
    				}
    				selectedData = null;
    				ec.log("End - deleteList()");
    				return GO_LIST;
    			} catch (RuntimeException ex) {
    				ec.handleError(ERR_DELETE_LIST, ex);
    				UtilGui.setJSFErrorMessage("error_delete_list", ex);
    				return GO_LIST;
    			}
    		}
    		// If any other error...
    		return GO_ERROR;
    	}
     
    	// ------------------- SPECIAL FEATURES -----------------------------//
    	/**
             * Get current language (no ISO code, but int value from the DB)
             */
    	public Integer getCurrentLanguageId() {
    		ec.log("Begin - getCurrentLanguage()");
    		int result;
    		String language = FacesContext.getCurrentInstance().getViewRoot().getLocale().getLanguage();
    		ec.log("getCurrentLanguage(), language:" + language);
    		result = LanguageServiceImpl.convertFromIso(language);
    		ec.log("End - getCurrentLanguage(), result:" + result);
    		return result;
    	}
     
    	/**
             * Delete entity actually in "selectedData" from "dataList" object
             */
    	private void deleteSelectedFromDataList() {
    		ec.log("Begin - deleteSelectedFromDataList(), dataList size: " + dataList.size());
    		for (int i = 0; i < dataList.size(); i++) {
    			Product module = dataList.get(i);
    			if (module.equals(selectedData))
    				dataList.remove(i);
    		}
    		ec.log("End - deleteSelectedFromDataList(), dataList size: " + dataList.size());
    	}
     
    	/**
             * Hide show multi-langue table
             */
    	public void showHideMessageList() {
    		String multi = UtilGui.getTranslationText("common_multiLanguage");
    		String mono = UtilGui.getTranslationText("common_monoLanguage");
     
    		lblShowHide = isMutliLanguageDisplay ? mono : multi;
    		jsfDescription.setRendered(!isMutliLanguageDisplay);
    		jsfMessageList.setRendered(isMutliLanguageDisplay);
     
    		// set opposite value
    		isMutliLanguageDisplay = (!isMutliLanguageDisplay);
    	}
     
    	public void setProductService(ProductService productService) {
    		this.productService = productService;
    	}
     
    	public HtmlInputText getTxtId() {
    		return txtId;
    	}
     
    	public void setTxtId(HtmlInputText txtId) {
    		this.txtId = txtId;
    	}
     
    	public boolean isDisabled() {
    		return disabled;
    	}
     
    	public void setDisabled(boolean disabled) {
    		this.disabled = disabled;
    	}
    	public List<SelectItem> getProducts()
    	{
    		List<SelectItem> result = new ArrayList<SelectItem>();
    		List<Product> products = this.productService.getProducts();
    		for (Product product : products) {			
    			SelectItem item = new SelectItem(product.getId().getProductId(), product.getDescription());
    			result.add(item);
    		}
    		return result;
    	}
     
    	public void change(ValueChangeEvent event) 	{
    		this.marketId = (String) event.getNewValue();
    	}
     
     
    }
    Le problème qui apparait est le suivant, je n arrive pas a setter a chacun des attributs la valeur qui provient de ma page jsf

    si quelqu un a une idée qu il n hésite pas

    a+

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 4
    Points : 5
    Points
    5
    Par défaut
    Hello ,

    je pense que tu as un probleme de type , tu peux donner le code par exemple qui correspond à #{brandGui.brands} pour voir.
    Plus précisément pour savoir si la value de selectItem est de type String ,car c'est ce que tu attends dans ton managed-bean productGui.

  3. #3
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Points : 2 336
    Points
    2 336
    Par défaut
    Citation Envoyé par seb4j
    Hello ,

    je pense que tu as un probleme de type , tu peux donner le code par exemple qui correspond à #{brandGui.brands} pour voir.
    Plus précisément pour savoir si la value de selectItem est de type String ,car c'est ce que tu attends dans ton managed-bean productGui.
    salut,

    le probleme était que j avais oublier de mettre des "value" dans les autres champs

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Select values mysql
    Par pittacos dans le forum Langage SQL
    Réponses: 4
    Dernier message: 27/08/2008, 12h03
  2. probleme selectonemenu selection
    Par soufyan dans le forum JSF
    Réponses: 8
    Dernier message: 30/08/2007, 03h48
  3. [C#] Gridview Selected Value non définie
    Par carlosm95 dans le forum ASP.NET
    Réponses: 2
    Dernier message: 10/01/2007, 01h16
  4. h:selectOneMenu selected item
    Par *alexandre* dans le forum JSF
    Réponses: 2
    Dernier message: 26/07/2006, 14h30
  5. <select value="1">1</select>
    Par picsoun dans le forum Langage
    Réponses: 6
    Dernier message: 18/03/2006, 01h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo