I managed to insert a datepicker inside the detailsview. However, the dates on the details view form does not bind to the gridview like the other bound field. It is left blank when passed to Gridview. Please see code below.
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Request_ID" DataSourceID="EntityDataSource1" Font-Size="Small" GridLines="Horizontal" Height="50px" HorizontalAlign="Left" Width="590px" DefaultMode="Insert" OnItemInserted="DetailsView1_ItemInserted">
<AlternatingRowStyle BackColor="#F7F7F7" />
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" HorizontalAlign="Center" Width="400px" />
<Fields>
<asp:BoundField DataField="CS_Rep" HeaderText="CS_Rep" SortExpression="CS_Rep" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Date_Rcvd">
<EditItemTemplate>
<asp:TextBox id="Date_Rcvd" Text='<%# Eval("Date_Rcvd") %>' runat="server" Width="200px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:label ID="lbl1" runat="server" Text='<%# Bind("Date_Rcvd") %>'></asp:label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Time_Rcvd" HeaderText="Time_Rcvd" SortExpression="Time_Rcvd" >
<ControlStyle Width="200px" />
</asp:BoundField>
//for gridview
``
my aspx.cs
aspx.cs
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
GridView1.DataBind();
}
Related
I am relatively new to Apex:
Im trying to save a related field via my visualforce page, the apex class currently in use returns this error:
Update failed. First exception on row 0 with id 000000000000000; first error: INVALID_ID_FIELD, record id cannot be empty key: []
Error is in expression '{!save}' in component in page masseditcontact: Class.ContactExt.save: line 28, column 1
What I have tried so far is to refer to the field on my visualforce page - Contact.Account.Organization_Size__c - however when I try and update it with the save method in my class it seems to throw the error above.
public class ContactExt {
public Contact record {get; set;}
public String city {
get {
return record.Account.Organization_Size__c;
}
private set;
}
public ContactExt(ApexPages.StandardSetController controller) {
record = (Contact)controller.getRecord();
}
public PageReference save(){
update record
//try{
//update record;
//}
//catch (QueryException e)
//{
//record = new Contact();
//}
return null;
}
}
Visualforce markup
<apex:page standardController="Contact" extensions="ContactExt" recordSetVar="unused" sidebar="true" showHeader="true">
<apex:outputPanel rendered="{!$User.UIThemeDisplayed == 'Theme4d' || contains($CurrentPage.URL, 'lightning.force.com')}">
<apex:stylesheet value="{!URLFOR($Resource.SLDS221, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
<apex:stylesheet value="{!$Resource.MassEditCSS}" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"></link>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"></link>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</apex:outputPanel>
<apex:includeScript value="{!$Resource.UtilJS}" />
<apex:includeScript value="{!$Resource.LightningMassEditJS}" />
<apex:includeScript value="support/api/42.0/interaction.js"/>
<apex:includeScript value="support/console/42.0/integration.js"/>
<div class="mass-update-mass-edit" id="mass-update-mass-edit">
<div role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open" id="cancel-modal">
<div class="slds-modal__container">
<div class="slds-modal__header">
<button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="closeCancelModal();">
<svg class="slds-button__icon slds-button__icon--large" aria-hidden="true">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{!URLFOR($Resource.SLDS221, '/assets/icons/utility-sprite/svg/symbols.svg#close')}"></use>
</svg>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="header43" class="slds-text-heading--medium">Return</h2>
</div>
<div class="slds-modal__content slds-p-around--medium">
<p>Are you sure you wish to return?</p>
</div>
<div class="slds-modal__footer">
<button class="slds-button slds-button--neutral" onclick="closeCancelModal();">No</button>
<button class="slds-button slds-button--brand" onclick="goBack();">Yes</button>
</div>
</div>
</div>
<div class="slds-backdrop slds-backdrop--open" id="cancel-modal-backdrop"></div>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlock >
Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.
</apex:pageBlock>
<apex:pageBlockButtons >
<apex:outputPanel rendered="{!$User.UIThemeDisplayed == 'Theme4d' || contains($CurrentPage.URL, 'lightning.force.com')}">
<apex:commandButton value="Save" action="{!save}" status="lightningSavingStatus" reRender="table" styleClass="slds-button slds-button--neutral slds-button--brand" />
<apex:commandButton value="Return" onclick="openCancelModal();" styleClass="slds-button slds-button--neutral" reRender="table" />
<apex:actionStatus id="lightningSavingStatus" >
<apex:facet name="start" >
<div id="spinning" class="slds-spinner_container">
<div class="slds-spinner--brand slds-spinner slds-spinner--medium" role="alert">
<span class="slds-assistive-text">Loading</span>
<div class="slds-spinner__dot-a"></div>
<div class="slds-spinner__dot-b"></div>
</div>
</div>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
<apex:outputPanel rendered="{!$User.UIThemeDisplayed != 'Theme4d' && !contains($CurrentPage.URL, 'lightning.force.com')}">
<apex:commandButton value="Save" action="{!save}" status="savingStatus" reRender="table" />
<apex:commandButton value="Return" action="{!cancel}" onclick="return confirmCancel()" />
<apex:actionStatus id="savingStatus" >
<apex:facet name="start" >
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!selected}" var="a" id="table">
<apex:column headerValue="Name">
<apex:inputField value="{!a.Name}"/>
</apex:column>
<apex:column headerValue="Phone">
<support:clickToDial number="{!a.Phone}" entityId="{!a.Id}"/>
</apex:column>
<apex:column headerValue="Mobile Phone">
<apex:inputField value="{!a.MobilePhone}"/>
</apex:column>
<apex:column headerValue="Email">
<apex:inputField value="{!a.Email}"/>
</apex:column>
<apex:column headerValue="Title">
<apex:inputField value="{!a.Title}"/>
</apex:column>
<apex:column headerValue="Account">
<apex:inputField value="{!a.AccountId}"/>
</apex:column>
<apex:column headerValue="Description">
<apex:inputField value="{!a.Description}"/>
</apex:column>
<apex:column headerValue="Organisation Size">
<apex:inputField value="{!a.Organization_Size__c}"/>
</apex:column>
<apex:column headerValue="Organisation Size">
<apex:inputField value="{!a.Account.Organization_Size__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</div>
I am trying to get the value of a textbox on a zul page by using some kind of getValue method. I should handle this on the zul page, not on a controller. I need to assign a listbox cell (which is the first cell of the list box below) with a value coming from the textbox.
<listcell>
<label value="" />
</listcell>
<listcell>
<toolbarbutton visible="true"
image="/resources/images/icons/1616/page_text.gif" />
</listcell>
<listcell>
<label value="#{file.name}" />
</listcell>
<listcell>
<toolbarbutton forward="onClick=onRemoveMultipleFiles"
visible="true" id="newFileAndCommentRemove" image="/resources/images/icons/1616/delete.png" />
</listcell>
</listitem>
If what you want is that after the textbox is filled then the first cell will fill with its value you can do it like this:
put an id into the label in the cell
put an onChange operation in the textbox so when the textbox change you can put its value into the cell
like this:
<textbox id="textbox" onChange="label.setValue(self.getValue())"/>
<listbox id="newFileAndComment">
<listhead>
<listheader label="1" width="30px" />
</listhead>
<listitem self="#{each=file}">
<listcell>
<label id="label"/>
</listcell>
</listitem>
I have a problem with xforms, how refresh only rich:panel when I choose value from h:selectOneMenu :
<!--<h:form> call bean but--> <form><!--open start page-->
<h:selectOneMenu id="add" onchange="submit()" <!-- can't find context , error orbeon/java--> >
<!-- is not working <a4j:support event="onchange" actionListener="#{bean.action}"/> -->
<s:selectItems value="#{bean.List()}" var="message" itemValue="#{message}" label="#{message}" />
</h:selectOneMenu>
</form>
more Code JSF :
<form>
<rich:panel styleClass="DocumentBody" id="documentPanel"
name="panell" style="margin-top:10px; height:90px;">
<f:facet styleClass="documentHeader" name="header"></f:facet>
<div id="documentTest" class="actionButtons">
<div style="clear: both; height: 15px; width: 60px" />
<s:button id="addButton" value="#{messages['operation.save.button']}"
action="#{actionBean.generateNewName()}" reRender="confirm"
onclick="#{actionBean.generateNewName()};#{rich:component('confirm')}.show();return false;">
</s:button>
<s:button id="loadButton" value="#{messages['operation.load.button']}"
action="#{actionBean.loadDraft()}" reRender="documentTests,documentPanel,loadButton" />
<s:button id="deleteButton" value="#{messages['operation.delete.button']}"
action="#{actionBean.deleteDraft()}" reRender="documentTests,documentPanel,deleteButton" />
</div>
</rich:panel>
</form>
<h:form style="margin: 0;">
<h:selectOneMenu id="messageTypeAdd"
style="margin-right:5px; margin-top:-30px;margin-left:90px;"
valueChangeListener="#{actionBean.documentTestChange}"
enableManualInput="false" selectFirstOnUpdate="true"
directInputSuggestions="true" onchange="submit()">
<!-- submit() rerender all page, but i try refresh only modalPanel id="confirm" -->
<s:selectItems value="#{actionBean.getdocumentTestList()}"
var="message" itemValue="#{message}" label="#{message}" />
<!--a4j and f:ajax is not work, i try update JSF 1.2 to 2.0 -->
</h:selectOneMenu>
</h:form>
<rich:modalPanel id="confirm" autosized="true" width="300">
<f:facet name="header"></f:facet>
<rich:messages style="color:red;" globalOnly="true" />
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid>
<h:panelGrid columns="2">
<h:outputText value="#{messages['report.name.label']}" />
<h:inputText id="newDraftNameInput" value="#{actionBean.newDraftName}"
valueChangeListener="#{actionBean.newDraftNameChange}">
</h:inputText>
</h:panelGrid>
</h:panelGrid>
</a4j:outputPanel>
</rich:modalPanel>
hai i need to pass parameters from one jsp in the search-container-column-text to another jsp. i have displayed the results and i have added hyperlink at last of the column when it click it will open the edit.jsp page and i need to pass the courseid to that edit.jsp from the result.jsp. can any one tell me the solution?
edit.jsp
<%
PortletURL editCourseURL=renderResponse.createActionURL();
editCourseURL.setParameter(ActionRequest.ACTION_NAME,"editCourse");
%>
<%
String ns =renderRequest.getParameter("courseId");
System.out.println("hai hello "+ns);
//long n= Long.parseLong(ns);
System.out.println("hello world");
Course courses =CourseLocalServiceUtil.getCourse(3);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//sdf = new SimpleDateFormat("yyyy-MM-dd");
String sdate = sdf.format(courses.getSdate());
String edate = sdf.format(courses.getEdate());
String cname=courses.getCname();
String cdesc=courses.getCdesc();
System.out.println(sdate);
%>
<form action="<%=editCourseURL%>" method="post" id="register-form" >
<div class="label1">Course Name</div>
<input type="text" id="cname" name="cname" value="<%=cname%>"/><br />
<div class="label2">Course Description</div>
<input type="text" id="cdesc" name="cdesc" value="<%=cdesc%>"/><br/>
<div class="label3">Start Date</div>
<input type="date" name="sdate" id="sdate" value="<%=sdate%>"/><br/>
<div class="label4">End Date</div>
<input type="date" id="edate" name="edate" value="<%=edate%>" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<portlet:renderURL var="homeURL">
<portlet:param name="jspPage" value="/html/course/view.jsp"></portlet:param>
</portlet:renderURL>
--HOME--
result.jsp:
<%
int n=CourseLocalServiceUtil.getCoursesCount();
List courses = CourseLocalServiceUtil.getCourses(0,n);
if(Validator.isNull(courses))courses = new ArrayList();
%>
<portlet:renderURL var="edit">
<portlet:param name="jspPage" value="/html/course/edit.jsp"></portlet:param>
</portlet:renderURL>
<portlet:renderURL var="delete">
<portlet:param name="jspPage" value="/html/course/delete.jsp"></portlet:param>
</portlet:renderURL>
<liferay-ui:search-container delta="10" emptyResultsMessage="no-courses-were-found" >
<liferay-ui:search-container-results results="<%=courses%>" total="<%=courses.size()%>" />
<liferay-ui:search-container-row className="com.course.slayer.model.Course" modelVar="course" >
<liferay-ui:search-container-column-text name="Course Name" property="cname" />
<liferay-ui:search-container-column-text name="Course Description" property="cdesc" />
<liferay-ui:search-container-column-text name="Start Date" property="sdate" />
<liferay-ui:search-container-column-text name="End Date" property="edate" />
<liferay-ui:search-container-column-text name="Edit" href="<%=edit%>" value="edit">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="Delete" href="<%=delete%>" value="delete" />
</liferay-ui:search-container-row >
<liferay-ui:search-iterator />
</liferay-ui:search-container >
result.jsp:
You can pass parameter like this :-
<portlet:renderURL var="edit">
<portlet:param name="jspPage" value="/html/course/edit.jsp"></portlet:param>
<portlet:param name="courseName" value="<%=courseName%>"></portlet:param>
</portlet:renderURL>
<portlet:renderURL var="delete">
<portlet:param name="jspPage" value="/html/course/delete.jsp"></portlet:param>
<portlet:param name="courseName" value="<%=courseName%>"></portlet:param>
</portlet:renderURL>
HTH
I have a form with jsf2 and primefaces that contains a submit button that managed two things:
First: form validation with the update attribute and second launching a confirmation dialog box when validation succeeded and all of this are managed by:
update="myfieldset display"
so my problem is that when I click into the button validation: if validation don't succeeded : validation messages are displayed in the form : ok
but if the validation succeeded I must click a second time to display dialog box
anyone know how to solve this problem there?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<script type="text/javascript">
<!--
function effacer(formulaire){
for (var i=0; i<formulaire.length; i++){
if (formulaire.elements[i].type=="input" || formulaire.elements[i].type=="textarea" ) {formulaire.elements[i].value="";}
}
document.getElementById('contenu_input').value="";
}
//-->
</script>
<body>
<ui:composition template="./template_utilisateur.xhtml">
<ui:define name="content">
<h:form id="form" prependId="false" >
<p:fieldset id="myfieldset" legend="Nouveau message">
<p:messages id="msgs"/>
<h:panelGrid columns="3" style="margin-bottom:10px">
<h:outputLabel for="title" value="Titre : *"/>
<p:inputText id="title" style="width:340px;" value="#{messageController.titre}" required="true" requiredMessage="veuillez saisir un titre" label="Titre">
<f:validateLength minimum="10" />
</p:inputText>
<p:message for="title" display="icon"/>
<h:outputLabel for="city" value="Destinataire : *" />
<p:selectOneMenu id="city" value="#{messageController.destinataire}" label="Destinataire" required="true" requiredMessage="veuillez choisir au moins un destinataire" >
<f:selectItem itemLabel="Séléctionner déstinataire" itemValue="" />
<f:selectItems value="#{messageController.users}" />
</p:selectOneMenu>
<p:message for="city" id="msgSurname3" display="icon"/>
<h:outputLabel for="comm" value="Lié a La commande N° : " />
<p:selectOneMenu id="comm" label="Commande" value="#{messageController.idComm}" >
<f:selectItem itemLabel="Aucune commande" itemValue="" />
<f:selectItems value="#{messageController.id_c}" />
</p:selectOneMenu>
<p:message for="comm" id="msgSurnamse3" display="icon"/>
</h:panelGrid>
<h:outputLabel for="contenu" value="Contenu : *" />
<h:panelGrid columns="2">
<p:editor id="contenu" widgetVar="editer" value="#{messageController.message}" width="600" required="true" requiredMessage="Veuillez saisir le contenu du message" >
<f:validateLength minimum="10" />
</p:editor>
<p:message for="contenu" id="editorm" display="icon"/>
</h:panelGrid>
<h:panelGrid columns="3">
<p:commandButton id="submitButton" value="envoyer" update="myfieldset display" onclick="#{messageController.retournerDialog()}" icon="ui-icon-disk" />
<p:commandButton id="clearButton" type="reset" value="initialiser" onclick="editer.clear()"
icon="ui-icon-close" />
</h:panelGrid>
</p:fieldset>
<p:dialog header="Confirmation" widgetVar="dlg" showEffect="fade" hideEffect="fade" modal="true">
<h:panelGrid id="display" columns="1" cellpadding="4">
<h:outputText value="Titre : " />
<h:outputText value="#{messageController.titre}" id="model"/>
<h:outputText value="Déstinataire :" />
<h:outputText value="#{messageController.destinataire}" id="year"/>
<h:outputText value="Lié à la commande N° : " />
<h:outputText value="#{messageController.idComm}" id="manufacturer"/>
<h:outputText value="Contenu :" />
<h:outputText id="displxcay" value="#{messageController.message}" escape="false" />
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
and here the method to launch the dialog
public String retournerDialog(){
String retour = "";
if( getDestinataire() != "" && getMessage()!= "" && getTitre()!="" && getMessage().length()>9 && getTitre().length()>9){
retour="dlg.show()";
}
return retour;
}
thank you in advance
Update: thank you BalusC for your detailed response, I tested both of your answers but they don't work
here is the code of the button :
<p:commandButton id="submitButton" value="envoyer" update="myfieldset, display" action="#{messageController.showDialog}" icon="ui-icon-disk" />
and the managedBean :
private boolean showDialog;
public void showDialog() {
showDialog = true;
}
public boolean isShowDialog() {
return showDialog;
}
and with this code above the dialog doesn't appear even if validation is succeeded
: I think because action must return outcome string not boolean
and when I make :
<p:commandButton id="submitButton" value="envoyer" update="myfieldset, display" onclick="dlg.show();" icon="ui-icon-disk" />
it appear even if the validation failed
and to remind you
when I put a method above like this :
<p:commandButton id="submitButton" value="envoyer" update="myfieldset, display" onclick="#{messageController.retournerDialog()}" icon="ui-icon-disk" />
I have to click twice (I think one for validation and one for displaying dialog)for the dialog is displayed
also in the official documentation : they use this dialog with onclick attribute
do you have any other idea