Author: bleny Date: 2011-06-08 16:22:13 +0000 (Wed, 08 Jun 2011) New Revision: 1326 Log: fix Boats page Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BoatFilterComponent.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java trunk/wao-ui/src/main/webapp/Boats.tml Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BoatFilterComponent.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BoatFilterComponent.java 2011-06-08 09:52:47 UTC (rev 1325) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BoatFilterComponent.java 2011-06-08 16:22:13 UTC (rev 1326) @@ -31,6 +31,7 @@ import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; +import org.apache.tapestry5.ioc.annotations.Inject; import java.util.List; @@ -42,7 +43,7 @@ @InjectComponent private FeedBack filterFeedback; - @Parameter(required = true) + @Inject private ServiceBoat serviceBoat; /* Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2011-06-08 09:52:47 UTC (rev 1325) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2011-06-08 16:22:13 UTC (rev 1326) @@ -116,13 +116,16 @@ void onActivate(EventContext ec) { waoActivationContext = WaoActivationContext.newContextFromTapestry(ec); - sampleRowContextId = waoActivationContext.getSampleRowCode(); - getBoatFilter().setBoatImmatriculation( - waoActivationContext.getBoatImmatriculation()); - getBoatFilter().setShipOwnerName( - waoActivationContext.getShipOwnerName()); } + String[] onPassivate() { + WaoActivationContext waoActivationContext = WaoActivationContext.newEmptyContext(); + if (sampleRowContext != null) { + waoActivationContext.setSampleRowCode(sampleRowContext.getCode()); + } + return waoActivationContext.toStrings(); + } + @Property @Persist private SampleRow sampleRowContext; @@ -133,18 +136,16 @@ // creating contact and coming back to Boats. But this may break the page // filterComponent.resetFilter(); - if (boatSelectedImmatriculation != null && getBoatSelected() == null) { - layout.addFatal("L'immatriculation " + boatSelectedImmatriculation + - " ne correspond à aucun navire affichable. " + - "Veuillez à enlever cette immatriculation de l'url puis" + - " rechargez la page."); - boatSelectedImmatriculation = null; - } - boats = null; boatSelectedImmatriculation = null; companyBoatInfos = null; + getBoatFilter().setBoatImmatriculation( + waoActivationContext.getBoatImmatriculation()); + getBoatFilter().setShipOwnerName( + waoActivationContext.getShipOwnerName()); + + String sampleRowContextId = waoActivationContext.getSampleRowCode(); if (sampleRowContextId == null) { sampleRowContext = null; } else { @@ -160,9 +161,6 @@ public InputStream getStream() throws IOException { InputStream result = null; try { - if (log.isDebugEnabled()) { - log.debug("Filter sampleRow : " + getFilter().getSampleRow()); - } result = serviceBoat.exportBoatCsv(getBoatFilter()); } catch (WaoException eee) { throw new IOException(eee); @@ -174,49 +172,19 @@ /******************** FILTERS *******************/ - public ServiceBoat getServiceBoat() { - return serviceBoat; - } - @InjectComponent private BoatFilterComponent filterComponent; - @Property - private String sampleRowContextId; - /** Selected boat immatriculation for showing boatInfos */ @Persist private Integer boatSelectedImmatriculation; - /** Filters to apply on boats list */ -// @Persist -// private BoatFilter boatFilter; - - /** Current sampleRow from context */ -// @Persist -// private SampleRow sampleRow; - - /** Profession select */ -// @Persist -// private GenericSelectModel<Profession> professionSelectModel; -// -// @Property -// private String professionId; -// -// /** Used to manage view of filters zone */ -// @Persist -// private boolean filtersHidden; - -// @InjectComponent -// private Zone filtersZone; - /** * Filters to apply on boats list. * * @return the current BoatFilter to apply * @throws WaoException */ -// @Override public SamplingFilter getFilter() throws WaoException { return getBoatFilter(); } @@ -225,20 +193,6 @@ return filterComponent.getFilter(); } -// @Override -// protected boolean isAvailableDataForFiltersOnly() { -// return true; -// } - -// public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException { -// if (professionSelectModel == null) { -// List<Profession> professions = serviceReferential.getProfessions(); -// professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class, -// "code", "topiaId", propertyAccess); -// } -// return professionSelectModel; -// } - public boolean isFiltersVisible() { return filterComponent.getFiltersVisible(); } @@ -252,67 +206,14 @@ } } - /** - * EVENT_SELECTED :: reset submit button for filtersForm. Reset filters and sampleRow from context. - */ void onSelectedFromReset() { - // Suppress persistant boat filter and sampleRowId in url context. - sampleRowContextId = null; - sampleRowContext = null; - filterComponent.setSampleRow(null); filterComponent.resetFilter(); } - /** - * EVENT_SELECTED :: search sumit button for filtersForm. Get profession from selectModel to add it in filters. - * Other filters are managed by AbstractFilteredPage superclass. - * - * @throws WaoException for business errors - * @see AbstractFilteredPage#onSelectedFromSearch() - */ -// @Override -// public void onSelectedFromSearch() throws WaoException { -// super.onSelectedFromSearch(); -// if (log.isDebugEnabled()) { -// log.debug("FILTER : facadeName=" + boatFilter.getFacadeName()); -// log.debug("FILTER : sectorName=" + boatFilter.getSectorName()); -// log.debug("FILTER : sampleRow=" + boatFilter.getSampleRow()); -//// log.debug("FILTER : profession=" + boatFilter.getProfession()); -// log.debug("FILTER : boatName=" + boatFilter.getBoatName()); -// log.debug("FILTER : boatImmatriculation=" + boatFilter.getBoatImmatriculation()); -// log.debug("FILTER : boatDistrictCode=" + boatFilter.getBoatDistrictCode()); -// log.debug("FILTER : company=" + boatFilter.getCompany()); -// } -// Profession profession = getProfessionSelectModel().findObject(professionId); -// boatFilter.setProfession(profession); -// } - - /** - * EVENT_SUCCESS :: for filtersForm. Reset persitant data to have new data using filters selected. - * - * @return the filtersZone if it's a refresh data for select, or the page otherwise - * @throws WaoException for business errors - */ -// Object onSuccessFromFiltersForm() throws WaoException { -// if (isEdited()) { -// return filtersZone.getBody(); -// } -// // Suppress persistant boats list to get new one with filter -// boats = null; -// // Suppress persistant immatriculation for boat selected -// boatSelectedImmatriculation = null; -// // Suppress persistant boat informations for boat selected -// companyBoatInfos = null; -// return this; -// } - @Log Object onSuccessFromFiltersForm() throws WaoException { - // Suppress persistant boats list to get new one with filter boats = null; - // Suppress persistant immatriculation for boat selected boatSelectedImmatriculation = null; - // Suppress persistant boat informations for boat selected companyBoatInfos = null; return boatsZone.getBody(); } @@ -462,9 +363,9 @@ @Inject private WaoManager manager; - public boolean isActivityCalendarImportRun() { - return manager.isActivityCalendarImportRun(); - } +// public boolean isActivityCalendarImportRun() { +// return manager.isActivityCalendarImportRun(); +// } public Block getActiveBoatInfosBlock() { if (boatInfosEditable) { @@ -528,7 +429,6 @@ return company; } - /** * Used to get the selected boat. * @@ -536,11 +436,16 @@ * @throws WaoException */ public Boat getBoatSelected() throws WaoException { - if (log.isDebugEnabled()) { - log.debug("selected imma : " + boatSelectedImmatriculation); - log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation)); + Boat boatSelected; + if (boatSelectedImmatriculation == null) { + boatSelected = null; + } else { + boatSelected = getBoats().get(boatSelectedImmatriculation); + if (boatSelected == null) { + throw new IllegalStateException("immatriculation selected among an obsolete list of boats"); + } } - return getBoats().get(boatSelectedImmatriculation); + return boatSelected; } /** Modified: trunk/wao-ui/src/main/webapp/Boats.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Boats.tml 2011-06-08 09:52:47 UTC (rev 1325) +++ trunk/wao-ui/src/main/webapp/Boats.tml 2011-06-08 16:22:13 UTC (rev 1326) @@ -44,8 +44,7 @@ </a> </div--> <t:boatFilterComponent t:id="filterComponent" - t:user="user" - t:serviceBoat="serviceBoat"/> + t:user="user" /> </fieldset> </div> @@ -159,7 +158,7 @@ <!-- BOATINFOS:: Informations du navire sélectionné --> <t:if t:test="boatSelectedImmatriculation"> <t:zone t:id="boatInfosZone" t:update="show" class="fleft" id="so-boats-boat-infos"> - <t:unless t:test="activityCalendarImportRun"> + <!--t:unless t:test="activityCalendarImportRun"--> <!-- HEADER For admin --> <t:if t:test="user.admin"> <h2>${format:wao.ui.misc.infosAbout=boatSelected.name}</h2> @@ -208,7 +207,7 @@ Veuillez réessayer ultérieurement. </div> </p:else> - </t:unless> + <!--/t:unless--> </t:zone> <!-- BOATINFOS:: DISPLAY MODE -->