点击<p:commandButton>
后多次调用动作侦听器方法。
Bean声明和被调用方法的代码
@Named(value = "planovaniBean")
@SessionScoped
public class PlanovaniBean implements Serializable{
public void naplanuj(ActionEvent e){
//some local var def
//retrieving data from db
uzavriDB();
Slouzici seznamSlouzicich = nactiSlouzici();
poradiSD = dejPoradiSluzbodnu(seznamSlouzicich);
//searching result
while(vysledek == null){
vysledek = naplanuj(mezPresMiru<2?2:25,mezPresMiru, mezPaSoNe, mezSv,seznamSlouzicich, poradiSD,true);
//changing mez...
}
//searching for better result
mezPresMiru=vysledek.getMaxsluzebpresmiru();
float minulaPresMiru = mezPresMiru;
while(true){
boolean ukonci = true;
SluzboDen pom = naplanuj(25,mezPresMiru, mezPaSoNe, mezSv, seznamSlouzicich, poradiSD,true);
if (pom != null){
vysledek = pom;
ukonci = false;
}
if(ukonci) break;
minulaPresMiru = mezPresMiru;
mezPresMiru = vysledek.getMaxsluzebpresmiru();
}
//searching for better result using differ algo
mezPresMiru = minulaPresMiru+(float)0.01;
while(true){
boolean ukonci = true;
SluzboDen pom = naplanuj(25,mezPresMiru, mezPaSoNe, mezSv, seznamSlouzicich, poradiSD,false);
if (pom != null){
vysledek = pom;
ukonci = false;
}
if(ukonci) break;
mezPresMiru = vysledek.getMaxsluzebpresmiru();
}
vypisKolik(vysledek,seznamSlouzicich);//just printing some output
navrhSluzeb = vysledek;
naplanovano = true;
vPlanovani = false;
}
来自:
<ui:composition template="/common/index.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ListPozadavkyTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form id="PozadavkyListForm" style="font-size: 92% !important;">
<p:remoteCommand name="rc_mousedown" actionListener="#{pozadavkyBean.vyberZacatek()}"/>
<p:remoteCommand name="rc_mouseup" actionListener="#{pozadavkyBean.vyberKonec()}"/>
<p:dataTable id="datalist" value="#{pozadavkyBean.pozadavkyNaMesic}" var="item"
rowKey="#{item[0]}"
rowIndexVar="rowIndex"
>
<f:facet name="header">
<p:outputLabel style="font-weight: bold; font-size: 110% !important;" id="headerMesic" value="#{pozadavkyBean.proMesic()} - Úprava požadavků"/>
</f:facet>
<p:columns id="sloupce" value="#{pozadavkyBean.columns}" var="column" columnIndexVar="colIndex"
width="#{pozadavkyBean.sirkaSloupce(colIndex)}"
style=" background-color: #{pozadavkyBean.cellColor(colIndex)}; padding-bottom: 0 !important; padding-top: 0 !important;">
<f:facet name="header">
<h:outputText value="#{colIndex == 0? 'X':column.header}" style="color: #{colIndex == 0? '#dfeffc':'#2e6e9e'}; font-size: #{colIndex == 0? '150%':'%92'} !important"/>
</f:facet>
<p:outputLabel value="#{item[colIndex]}" style="width:100%; color: #000000; " rendered="#{pozadavkyBean.renderedCellvII(colIndex, item[colIndex], 1)}" onmousedown="rc_mousedown([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])" onmouseup="rc_mouseup([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])"/>
<p:outputLabel value="#{item[colIndex]}" style="width:100%; color: #000000" rendered="#{pozadavkyBean.renderedCellvII(colIndex, item[colIndex], 3)}"/>
<p:outputLabel value="______" style="width:100%; margin-left: -10px; font-size: 150% !important; color: #{pozadavkyBean.cellColor(colIndex)}" rendered="#{pozadavkyBean.renderedCellvII(colIndex, item[colIndex], 2)}" onmousedown="rc_mousedown([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])" onmouseup="rc_mouseup([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])"/>
<p:outputLabel value="X" style="font-size: 150% !important; color: #{pozadavkyBean.cellColor(colIndex)}" rendered="#{colIndex == 0? 'True':'False'}"/>
<f:facet name="footer">
<h:outputText value="#{colIndex == 0? 'X':column.header}" style="color: #{colIndex == 0? '#dfeffc':'#2e6e9e'}; font-size: #{colIndex == 0? '150%':'%92'} !important"/>
</f:facet>
</p:columns>
</p:dataTable>
<p:contextMenu id="cmenu" for="PozadavkyListForm">
<p:menuitem value="X" actionListener="#{pozadavkyBean.ulozPozadavky('X')}" update="datalist"/>
<p:menuitem value="ŘD" actionListener="#{pozadavkyBean.ulozPozadavky('ŘD')}" update="datalist"/>
<p:menuitem value="SC" actionListener="#{pozadavkyBean.ulozPozadavky('SC')}" update="datalist"/>
<p:menuitem value="SV" actionListener="#{pozadavkyBean.ulozPozadavky('SV')}" update="datalist"/>
<p:menuitem value="LK" actionListener="#{pozadavkyBean.ulozPozadavky('LK')}" update="datalist"/>
<p:menuitem value="LD" actionListener="#{pozadavkyBean.ulozPozadavky('LD')}" update="datalist"/>
<p:menuitem value="SK" actionListener="#{pozadavkyBean.ulozPozadavky('SK')}" update="datalist"/>
<p:menuitem value="SD" actionListener="#{pozadavkyBean.ulozPozadavky('SD')}" update="datalist"/>
<p:menuitem value="Vynulovat" actionListener="#{pozadavkyBean.ulozPozadavky('')}" update="datalist"/>
</p:contextMenu>
</h:form>
<br/>
<br/>
<h:form id="PozadavkyListFormCalendar" style="font-size: 92% !important;">
<p:remoteCommand name="rc_mousedownII" actionListener="#{planovaniBean.vyberZacatek()}"/>
<p:remoteCommand name="rc_mouseupII" actionListener="#{planovaniBean.vyberKonec()}"/>
<p:dataTable id="dnySvozu" value="#{planovaniBean.dnySvozu}" var="item"
rowKey="#{item[0]}"
rowIndexVar="rowIndex"
>
<f:facet name="header">
<p:outputLabel style="font-weight: bold; font-size: 110% !important;" id="headerMesic" value="#{pozadavkyBean.proMesic()} - svoz do Líní"/>
</f:facet>
<p:columns id="sloupce" value="#{planovaniBean.columns}" var="column" columnIndexVar="colIndex"
width="#{pozadavkyBean.sirkaSloupce(colIndex)}"
style=" background-color: #{pozadavkyBean.cellColor(colIndex)}; padding-bottom: 0 !important; padding-top: 0 !important;">
<f:facet name="header">
<h:outputText value="#{colIndex == 0? 'X':column.header}" style="color: #{colIndex == 0? '#dfeffc':'#2e6e9e'}; font-size: #{colIndex == 0? '150%':'%92'} !important"/>
</f:facet>
<p:outputLabel value="#{item[colIndex]?'✔':'_____'}"
style="width:100%; #{item[colIndex]?'':'margin-left: -10px; font-size: 150% !important'};color: #{item[colIndex]?'#000000':pozadavkyBean.cellColor(colIndex)}"
onmousedown="rc_mousedownII([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])"
onmouseup="rc_mouseupII([{name:'jmeno',value:#{rowIndex}},{name:'den',value:#{colIndex}}])"
rendered="#{colIndex == 0?'false':'true'}"
/>
<p:outputLabel value="CHRA"
rendered="#{colIndex == 0?'true':'false'}"
style="width:100%; color: #{pozadavkyBean.cellColor(colIndex)}"
/>
</p:columns>
</p:dataTable>
<p:contextMenu id="cmenuII" for="PozadavkyListFormCalendar">
<p:menuitem value="Jede" actionListener="#{planovaniBean.nastavSvoz(true)}" update="dnySvozu"/>
<p:menuitem value="Vynulovat" actionListener="#{planovaniBean.nastavSvoz(false)}" update="dnySvozu"/>
</p:contextMenu>
</h:form>
<br/>
<h:form id="planovani">
<p:commandButton value="Naplánuj" actionListener="#{planovaniBean.naplanuj}" id="btNaplanuj"
onclick="PF('dlg').show()"/>
</h:form>
</ui:define>
</ui:composition>
模板:
<h:body>
#{loggedBean.prechodNeprihlasen()}
<p:growl id="growl" life="3000" />
<p:dialog position="center" widgetVar="dlg"
header="Plánuji..."
resizable="false"
closable="false"
draggable="false"
modal="true">
<h:form>
<p:inputTextarea id="txt_area" rows="25" cols="70" disabled="true" value="#{planovaniBean.text}"
style=" background-color: #ffffff; color: #000000" autoResize="false"/>
<br/>
<p:button id="tlacitko" disabled="#{planovaniBean.naplanovano?'False':'True'}" value="Kontrola"
onclick="PF('dlg').hide()" outcome="/scheduler/pozadavky/kontrola"/>
<p:commandButton id="tlacitko1" disabled="#{planovaniBean.nenaplanovano?'False':'True'}" value="OK"
onclick="PF('dlg').hide()"/>
<p:poll interval="1" update="txt_area tlacitko tlacitko1" async="True"/>
</h:form>
</p:dialog>
<p:layout fullPage="true">
<p:layoutUnit position="west" size="210" header="" collapsible="true">
<h:form>
<p:menu>
<p:submenu label="Administrace" rendered="#{loggedBean.loggedAsAdmin}">
<p:menuitem value="Uživatelé" />
<p:menuitem value="Odstranění uživatele"/>
<p:menuitem value="Změna uživatele"/>
</p:submenu>
<p:submenu label="Plánování" rendered="#{loggedBean.logged}">
<p:menuitem value="Administrace sloužících" rendered="#{loggedBean.loggedAsScheduler}" />
<p:menuitem value="Požadavky" rendered="#{loggedBean.loggedAsBFU}" outcome="/users/pozadavky/List"/>
<p:menuitem value="Naplánuj" rendered="#{loggedBean.loggedAsScheduler}" outcome="/scheduler/pozadavky/prechodPlan"/>
<p:menuitem value="Změna služby" rendered="#{loggedBean.loggedAsScheduler}"/>
</p:submenu>
<p:submenu label="Přehledy" rendered="#{loggedBean.logged}">
<p:menuitem value="Služby" />
<p:menuitem value="Statistiky"/>
<p:menuitem value="Rozkazy" />
</p:submenu>
<p:submenu label="Osobní" rendered="#{loggedBean.logged}">
<p:menuitem value="Osobní údaje" />
<p:menuitem value="Změna hesla" outcome="/common/zmenahesla"/>
<p:menuitem value="Odhlásit" action="#{logoutBean.logout()}" />
</p:submenu>
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center" id="centerPanel">
<ui:insert name="body"/>
</p:layoutUnit>
</p:layout>
</h:body>
我不知道要添加什么来更好地描述问题。已经阅读了几乎所有关于多功能呼叫吸气器的文章,但不要认为这是我的问题。
答案 0 :(得分:0)
用您的语言阅读代码非常令人困惑,请您用英语发布相关部分?我不知道你的方法或变量是做什么或意味着什么。
进一步检查后,我发现您在操作方法中多次调用您的操作方法。这就是它被多次调用的原因。
编辑:忘了我说的话,另一个用户指出它不是同一种方法,这是正确的。