【问题标题】:the data on my database are not updatd when i change the value of p:selectBooleanCheckbox , but it works with the inputText [duplicate]当我更改 p:selectBooleanCheckbox 的值时,我的数据库上的数据没有更新,但它适用于 inputText [重复]
【发布时间】:2017-03-27 18:07:27
【问题描述】:

当我想更新 <p:selectBooleanCheckbox> 的值并单击更新按钮时,它的值在数据库上不会改变,但是当我将其替换为 . 这是我的代码:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:evoice="http://ccs.tn/taglib/evoice">
    <ui:include src="CloseTicketDialog.xhtml" />

    <div class="form-body pal">
        <div class="row">
            <p:outputLabel for="call_from_tel_number"
                styleClass="col-md-2 control-label" value="Numéro Entrant" />
            <div class="col-md-3">
                <div class="input-icon right">
                    <i class="fa fa-phone" />
                    <p:inputText id="call_from_tel_number" maxlength="32" size="9"
                        value="#{ticketController.ticket.callFromTelNumber}"
                        validatorMessage="Numéro Entrant : Composé au minimum par 8 chiffres dans [0..9]."
                        styleClass="form-control">
                        <f:validateRegex pattern="[0-9\s]*" />
                        <f:validateLength minimum="8" maximum="32" />
                        <p:ajax event="blur" id="ajax_call" disabled="#{ticketController.ticket.ticketId ne null}"
                            process="call_from_tel_number,form:growl" 
                            update="form:growl,form:tab_view:lastName, form:tab_view:firstName"
                            listener="#{ticketController.queryOldTickets(ticketController.ticket)}"
                            onstart="PF('statusDialog').show()"
                            oncomplete="PF('statusDialog').hide()"/>
                    </p:inputText>
                </div>
            </div>
            <p:outputLabel for="reply_to_tel_number" value="Deuxièmme Numéro"
                styleClass="col-md-3 control-label" />
            <div class="col-md-3">
                <div class="input-icon right">
                    <i class="fa fa-phone" />
                    <p:inputText id="reply_to_tel_number" maxlength="32" size="9"
                        readonly="{ticketController.ticket.ticketId ne null}"
                        value="#{ticketController.ticket.otherPhonenum}"
                        validatorMessage="Deuxièmme Numéro : Accepte seulement des chiffres dans [0..9]."
                        styleClass="form-control">
                        <f:validateRegex pattern="[0-9]*" />
                    </p:inputText>
                </div>
            </div>
        </div>
                <div class="form-group" />
        <div class="row">
            <p:outputLabel for="telOwner" value="proprietaire de num"
                styleClass="col-md-2 control-label" />
            <div class="col-md-3">
                <div class="input-icon right">
                      <p:selectBooleanCheckbox  selected="true"  id="telOwner" value="#{ticketController.ticket.phoneLineOwner}"  />          

                </div>
            </div>
        </div>

有什么问题?当我使用p:inputText 时“telOwner”的值会更新,而当我使用p:selectBooleanCheckbox 时它不会更新?

【问题讨论】:

  • 相关关联托管bean的代码是什么样子的?
  • 这是控制器:
  • 能否将控制器的代码添加到问题中?

标签: jsf dom primefaces


【解决方案1】:

这是控制器:

@Controller(value = "ticketController")
@Scope("view")
public class TicketController extends eVoiceController implements Serializable {
public String saveTicket() {
    log.info("saveTicket");

    if (!isValide(ticket)) {
        return null ;
    }

    if (ticket.getOwner() == null) {
        ticket.setOwner(currentUser());
    } else {
        ticket.setLastUpdateBy(currentUser());
        ticket.setLastUpdateDate(new Timestamp(System.currentTimeMillis()));
    }

    Integer ticketId = ticketService.saveTicket(ticket);

    // ticket.getTicketCategories().size();

    if (closeTicketCmdBtn != null) {
        closeTicketCmdBtn.setDisabled(false);
    }

    showInfoMessage(i18n("ticket.saved.number", ticketId));

    log.info("TICKET[" + ticketId + "]");

    return null;
}

这是服务:

@Override
    @Transactional(readOnly = false)
    public Integer saveTicket(final Ticket ticket) {
        LoyaltyCard card = ticket.getLoyaltyCard();
        if (card != null) {
            card.setCreatedBy(ticket.getCreatedBy());
            card = loyaltyCardService.save(card);
        }
        ticket.setLoyaltyCard(card);

        Integer id = ticketDao.save(ticket).getTicketId();
        /**
         * @TODO run on seperate Thread
         */
        ruleService.assignSeverity(ticket);

        return id;
    }

这是实体代码:

@Column(name = "phone_line_owner")
@org.hibernate.annotations.Type(type = "yes_no")
private Boolean phoneLineOwner;

【讨论】:

    猜你喜欢
    • 2017-12-10
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多