Saving radio button selection - xpages

I've been playing around with this all day but cannot seem to get it to work the way I want it to :o(
I am writing an application that allows users to select a menu in the canteen. I would like a nice table like this:
The options for the various menus are saved on the document menu which the user selected on the previous screen (listing the week) - this is saved in the data source menu.
The user then selects what s/he wants for that week - they then press save and I need to create a selection document that contains M1, M2 or M3 in the field called Monday (mon), M1, M2 or M3 in the field called Tuesday (tue) etc.
Now matter what I did I could not get the options too line up as I wanted them using what I knew of XPages. I have now ended up with the code below (only added the code for the Monday (Montag) line to give you an idea of what I am doing. The same code is basically repeated for each day of the week (will use a repeat control later down the line). How do I now either 1) attach my XPages field to the variable (as you can see I am using pure BootStrap) or find the value of the selected option in SSJS so I can create a new document using JS?
Any help would be greatly appreciated.
<!-- ======================== Montag ================================== -->
<div class="row">
<div class="row">
<div class="col-md-2">
<xp:text escape="true" id="computedField1">Montag</xp:text>
</div>
<div class="col-md-3">
<label class="radio-inline">
<input type="radio" name="montag" id="Radios1" value="M1">
<xp:text escape="true" id="computedField3">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_1");}]]></xp:this.value>
</xp:text>
</input>
</label>
</div>
<div class="col-md-3">
<label class="radio-inline">
<input type="radio" name="montag" id="Radios2" value="M2">
<xp:text escape="true" id="computedField4">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_2");}]]></xp:this.value>
</xp:text>
</input>
</label>
</div>
<div class="col-md-3">
<label class="radio-inline">
<input type="radio" name="montag" id="Radios3" value="M3">
<xp:text escape="true" id="computedField5">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_3");}]]></xp:this.value>
</xp:text>
</input>
</label>
</div>
</div>
</div>
changes suggested by Mark:
here the image:
[]
and the code:
<div class="col-md-3">
<label class="radio-inline">
<xp:radio id="Radios1" groupName="mon" value="#{wahl.mon}">
<xp:text escape="true" id="computedField3">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_1");}]]></xp:this.value>
</xp:text>
</xp:radio>
</label>
</div>
<div class="col-md-3">
<label class="radio-inline">
<xp:radio id="Radios2" groupName="mon" value="#{wahl.mon}">
<xp:text escape="true" id="computedField4">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_2");}]]></xp:this.value>
</xp:text>
</xp:radio>
</label>
</div>
<div class="col-md-3">
<label class="radio-inline">
<xp:radio id="Radios3" groupName="mon" value="#{wahl.mon}">
<xp:text escape="true" id="computedField5">
<xp:this.value><![CDATA[#{javascript:menu.getItemValueString("mon_3");}]]></xp:this.value>
</xp:text>
</xp:radio>
</label>
</div>

If you set up the radio buttons like this, they render according to the specs. Note that I've added a binding to a viewScope parameter.
<div
class="col-md-3">
<xp:radio
text="option 1"
disableTheme="true"
styleClass="radio-inline"
id="radio1"
selectedValue="M1"
groupName="montag"
value="#{viewScope.montagSelected}">
</xp:radio>
</div>
It generates the following HTML (I'm using the default 'Bootstrap3' theme):
<div class="col-md-3">
<label
for="view:_id1:radio1"
class="radio-inline">
<input id="view:_id1:radio1"
type="radio"
name="view:_id1:montag"
value="M1"
onchangetrigger="early-onclick">
option 1
</label>
</div>

Related

access test data after test area in cypress

I have an html code with contains
<div class="form-card">
<h2 class="fs-title" test-data="area_1">
About DigCompEdu
</h2>
<p></p>
<label for="academic_teaching" class="question" test-data="question_1">
<b>1- </b>
</label>
<small id="academic_teachingHelp" class="form-text text-muted">
</small>
<div class="form-check question-form-check ">
<div class="row">
<div class="col-1">
<input class="radio" type="radio" value="0" id="3" name="2" test-data="answer_1" />
</div>
</div>
So, I have h1 with testdata name after that i have a form, this form contains question with multin check radio .. i want to access this check , not by just call ([test-data="answer_2"])
because i have another tips and don't want to check them as this one ,
i did smth like this but it's not working :
cy.get('[test-data="area_1"]~[test-data="answer_2"]').check({force: true})
Any one have another idea ?
It might be the ~ between the selectors, I haven't seen that before.
Does it work with a space between instead?
cy.get('[test-data="area_1"] [test-data="answer_2"]').check({force: true})
If the heading is followed by the form like this
<h2 class="fs-title" test-data="area_1">
About DigCompEdu
</h2>
<div class="form-check question-form-check ">
...
then you would query like this
cy.get('[test-data="area_1"]')
.next('.form-check') // next element on page
.find('[test-data="answer_2"]') // this looks inside '.form-check'
.check({force: true})

Xpages Partial refresh with HTML ID

I have an InputText which has a function onChange. This function triggers an HTML component with partial refresh. EveryClass in this DIV works great.
but If refreshID is a XPages Design Element Partial Refresh works fine but CSS class does not. For example. In this examle the div which has class named "card", when i click on it It collapse and expand. When The page loaded first It works great but after partial refresh Collapsing and expanding does not work. I do not want to use full refresh because I have added Loading indicator which works with partial refresh and does not work with full refresh. Is there any way to solve this problem. If anyone has a clue I can share full codes..
Thank You
<xp:div id="Results" styleClass="card">
<div class="card-header bg-transparent header-elements-inline">
<span class="card-title font-weight-semibold">
Find What you are looking for...
</span>
<div class="header-elements">
<div class="list-icons">
<i class="icon-help"></i>
<a class="list-icons-item" data-action="collapse"> </a>
<a class="list-icons-item" data-action="remove"> </a>
</div>
</div>
</div>
<div class="card-body">
<div class="form-group form-group-feedback form-group-feedback-left">
<xp:inputText style="width:100%;" id="CompanyName" value="#{viewScope.CompanyName}" styleClass="form-control border-success-300 border-1"> <xp:this.attrs>
<xp:attr name="placeholder" value="What is it You looking for?">
</xp:attr>
</xp:this.attrs>
<xp:typeAhead mode="full" minChars="2" ignoreCase="true" valueList="#{javascript:getCustomersList();}"> </xp:typeAhead>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial"
refreshId="Results"> <xp:this.action><![CDATA[#{javascript:getSearchResults(viewScope.CompanyName)}]]></xp:this.action>
</xp:eventHandler></xp:inputText>
<div class="form-control-feedback"> <i class="mt-2 icon-reading text-muted"> </i> </div> </div>
<div class="">
<xp:comboBox id="Staff" value="#{viewScope.Staff}" styleClass="form-control"> <xp:this.disabled><![CDATA[#{javascript:viewScope.CompanyName=="" || viewScope.CompanyName==null; }]]></xp:this.disabled>
<xp:selectItems> <xp:this.value><![CDATA[#{javascript:viewScope.Staff}]]></xp:this.value> </xp:selectItems>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="Results"> <xp:this.action><![CDATA[#{javascript:var fName = viewScope.CompanyName;var uName = viewScope.Staff;
getUrunDetails(fName, uName)}]]></xp:this.action> </xp:eventHandler></xp:comboBox></div><div class="">
<xp:label value="Lastest Order Date:" id="label3" styleClass="col-form-label"></xp:label></div> <div class=""><xp:inputText id="LatestOrderDate" value="#{viewScope.LatestOrderDate}" styleClass="text-right form-control border-success-300 border-1" disabled="true">
</xp:inputText> </div> </div>
</xp:div>
UPDATE-2
<div id="view:_id1:_id1766:Results" class="card">
<div class="card-header bg-transparent header-elements-inline"><span class="card-title font-weight-semibold">Ara...</span>
<div class="header-elements"><div class="list-icons"><a class="list-icons-item" href="#"><i class="icon-help"></i></a>
<a class="list-icons-item" data-action="collapse"></a><a class="list-icons-item" data-action="remove"></a></div></div></div>
<div class="card-body"><div class="form-group form-group-feedback form-group-feedback-left">
<span id="view:_id1:_id1766:_id2717" dojotype="ibm.xsp.widget.layout.data.TypeAheadReadStore" jsid="view__id1__id1766__id2717" minchars="2" mode="full"></span>
<div class="dijit dijitReset dijitInline dijitLeft dijitTextBox dijitComboBox dijitValidationTextBox form-control border-success-300 border-1" id="widget_view:_id1:_id1766:FirmaAdi" role="combobox" aria-haspopup="true" data-dojo-attach-point="_popupStateNode" lang="en" widgetid="view:_id1:_id1766:FirmaAdi" style="width: 100%;"><div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" data-dojo-attach-point="_buttonNode" role="presentation" style="display: none;"><input class="dijitReset dijitInputField dijitArrowButtonInner" value="▼ " type="text" tabindex="-1" readonly="readonly" role="button presentation" aria-hidden="true"></div><div class="dijitReset dijitValidationContainer"><input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="Χ " type="text" tabindex="-1" readonly="readonly" role="presentation"></div><div class="dijitReset dijitInputField dijitInputContainer"><input class="dijitReset dijitInputInner" name="view:_id1:_id1766:FirmaAdi" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" role="textbox" tabindex="0" id="view:_id1:_id1766:FirmaAdi" value="DÖKTAŞ DÖKÜMCÜLÜK TİC VE SAN. A.Ş." aria-invalid="false"><span class="dijitPlaceHolder dijitInputField" style="display: none;">Ne Aramıştınız?</span></div></div><div class="form-control-feedback"><i class="mt-2 icon-reading text-muted"></i></div></div><div><select id="view:_id1:_id1766:Urun" name="view:_id1:_id1766:Urun" class="form-control" size="1"> <option value="Staff 0</option>
<option value="Staff 1</option>
<option value="Staff 2</option>
<option value="Staff 3</option>
</select></div><div>
<label id="view:_id1:_id1766:label3" class="col-form-label">Son Sipariş:<a id="view:_id1:_id1766:link14" href="http://portal/xspFrmProposal.xsp?action=editDocument&documentId=FD0F115C68C2BD52432586950040A419" class="text-right mr-2 ml-2 r text-primary list-icons-item" target="_blank" data-popup="popover" data-trigger="hover" data-content="DÖKTAŞ DÖKÜMCÜLÜK TİC VE SAN. A.Ş. ye ait Sözleşme Formuna git..." data-original-title="Müşteri Bilgilerine Git" data-placement="bottom"><i class="icon-link2"></i></a></label></div><div><input type="text" value="11.03.2021 15:26:49" id="view:_id1:_id1766:SiparisTarihi" name="view:_id1:_id1766:SiparisTarihi" disabled="disabled" class="text-right form-control border-success-300 border-1"></div><div><label class="col-form-label">Son Teklif:<a id="view:_id1:_id1766:link12" href="http://portal.acarermetal.com.tr/ays/crm.nsf/xspFrmTeklif.xsp?action=editDocument&documentId=38ED7907DE9CFAD943258693003E7D3F" class="text-right mr-2 ml-2 r text-primary list-icons-item" target="_blank" data-popup="popover" data-trigger="hover" data-content="DÖKTAŞ DÖKÜMCÜLÜK TİC VE SAN. A.Ş. ye ait son teklif formuna git..." data-original-title="Müşteri Bilgilerine Git" data-placement="bottom"><i class="icon-link2"></i></a></label></div><div><input type="text" value="09.03.2021" id="view:_id1:_id1766:TeklifTarihi" name="view:_id1:_id1766:TeklifTarihi" disabled="disabled" class="text-right form-control border-success-300 border-1"></div><div><label class="col-form-label">Son Teklif Verilen Malzemeler:</label><textarea name="view:_id1:_id1766:Urunt" data-dojo-attach-point="focusNode,containerNode,textbox" autocomplete="off" class="dijitTextBox dijitTextArea dijitExpandingTextArea form-control elastic elastic-destroy dijitTextBoxDisabled dijitTextAreaDisabled dijitExpandingTextAreaDisabled dijitDisabled" tabindex="-1" lang="en" disabled="" aria-disabled="true" id="view:_id1:_id1766:Urunt" rows="1" widgetid="view:_id1:_id1766:Urunt" value="2 Ton FEMO 16995usd
" style="overflow: auto hidden; box-sizing: border-box; min-height: 72px; height: 68px;"></textarea></div></div></div>

Reveal modal failed to open Fondation 6

I'm trying to make a modal reveal for every Edit button just when i clicked onto the Edit button it doesnt open i did as mentionned onto the documentation for Foundation 6 .Here is my code.Please any help.
<ul class="button-group">
i give to every reveal modal an id based on the field id with that i would have
different ids and linked every Edit button with its modal
<li>
<a class="button tiny" data-open="editModal<?php echo $contact->id ;?>"
data-contact-id="<?php echo $contact->id;?>">Edit</a>
<!-- the modal edit start here -->
<div class="reveal large editmodal" id="editModal<?php echo $contact->id ;?>"
data-cid="<?php echo $contact->id ;?>" data-reveal>
<div class="grid-x grid-margin-x">
<div class="cell large-12"><h1>Edit Contact</h1></div>
</div>
form of the edit modal
<form action="#" id="editadress" method="post">
<div class="grid-x grid-margin-x">
<div class="cell large-6">
first name input field
<label>First Name
<input type="text" name="first_name" placeholder="Enter Your First Name"
value="<?php echo $contact->first_name; ?>">
</label>
</div>
<div class="cell large-6">
last name input field
<label>Last Name
<input type="text" name="last_name" value="<?php echo $contact->last_name; ?>"
placeholder="Enter Your Last Name">
</label>
</div>
</div>
submit button of the form
<div class="grid-x grid-margin-x">
<div class="cell large-12">
<input class="button big abutton right small" name="submit" type="submit" value="Submit"/>
</div>
</div>
</form>
close button of the modal
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<!--The modal edit ends here-->
</li>
<li>
<a class="button alert tiny">Delete</a>
</li>
</ul>

Date fields and BootStrap Extension Lib

I have a very simple form that I am trying to use BootStrap from the ExtLib with. Everything is fine until I add a field that is of type Date or Time. Any fields after that field are then off in the design. I would like the labels on the left and the fields on the right. As you can see in this example the "von" and "bis" fields are off once the "Datum" field is displayed (yes, I do see that "Jause" and "Mittagessen" are not aligned correctly, I'll see what the problem is there later :) I have tried everything but cannot see my mistake.
Here is what I am getting in Chrome:
And here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="document1" formName="fmTermin"></xp:dominoDocument>
</xp:this.data>
<div class="panel panel-default">
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Mitarbeiter_in</label>
<div class="col-sm-10">
<p class="form-control-static">
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:context.getUser().getFullName()}]]></xp:this.value>
</xp:text>
</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Standort</label>
<div class="col-sm-10">
<p class="form-control-static">
<xp:text escape="true" id="computedField2">
<xp:this.value><![CDATA[#{javascript:userName = context.getUser().getFullName();
#DbLookup(#DbName(), "vwMitarbeiterInNachStandort", userName, 2)}]]></xp:this.value>
</xp:text>
</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Kind</label>
<div class="col-sm-10">
<p class="form-control-static">
<xp:comboBox id="comboBox1" value="#{document1.nachname}" style="width:350px">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:userName = context.getUser().getFullName();
standort = #DbLookup(#DbName(), "vwMitarbeiterInNachStandort", userName, 2);
kinder = #DbLookup(#DbName(), "vwKindNachStandort", standort, 2);
kinder
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Jause</label>
<div class="col-sm-10">
<xp:checkBox text="Jause" id="checkBox1" value="#{document1.Jause}" checkedValue="1" uncheckedValue="0"
defaultChecked="true"
></xp:checkBox>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Mittagessen</label>
<div class="col-sm-10">
<xp:checkBox text="Mittagessen" id="checkBox2" value="#{document1.mittagessen}" checkedValue="1" uncheckedValue="0"
defaultChecked="true">
</xp:checkBox>
</div>
</div>
<div class="form-group">
<xp:label value="Datum" id="label1" for="datum" styleClass="control-label col-sm-2">
</xp:label>
<div class="col-sm-10">
<xp:inputText id="datum" value="#{document1.datum}" defaultValue="#{javascript:#Now()}">
<xp:dateTimeHelper></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="short"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Von</label>
<div class="col-sm-10">
<xp:inputText id="von" value="#{document1.von}" defaultValue="#{javascript:#Now()}">
<xp:dateTimeHelper></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="time" timeStyle="short"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Bis</label>
<div class="col-sm-10">
<xp:inputText id="bis" value="#{document1.bis}" defaultValue="#{javascript:#Now()}">
<xp:dateTimeHelper></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="time" timeStyle="short"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</div>
</div>
</form>
</div>
</div>
</xp:panel>
</xp:view>
I've copied your code and tested it with version 11 of the Extension Library and the built-in Bootstrap3.2.0 theme. I've changed the <form class="form-horizontal"> to a <div class="form-horizontal">. After that it looked Ok: Von und Bis were rendered just as the other labels.
A <form> is always created by the XPages engine automatically, so you don't need to add that yourself. The form-horizontal class in Bootstrap isn't restricted for use with a form tag only: it can be used just as well with a <div>.
Mark answered the question but I cannot seem to find the "Mark as Answered" flag in the comment! Here is his answer:
I've copied your code and tested it with v11 of the ExtLib and the built-in Bootstrap3.2.0 theme. I've changed the to a . Adding your own form tags to an XPage isn't a good idea. After that it looked Ok: Von und Bis were rendered just as the other labels

Joomla jQuery Registration extension + captcha

I'm using Joomla jQuery Registration extension which comes without any kind of botcheck feature and I'd like to add it but I don't know how I'd go about doing that. Here is the extension's code:
<?php
/**
* #title jQuery Dropdown Registration Module
* #version 1.7.2
* #package Joomla
* #author http://www.minitek.gr (Ioannis Maragos)
* #copyright Copyright (C) 2011 Minitek. All rights reserved.
* #license GNU General Public License version 2 or later.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<?php JHTML::_('behavior.formvalidation'); ?>
<?php /*<link rel="stylesheet" href="modules/mod_dropdown_registration/css/style.css" type="text/css" /> */?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=1.4.2" type="text/javascript"></script>
<script src="modules/mod_dropdown_registration/js/register.js" type="text/javascript"></script>
<?php
$user = JFactory::getUser();
$myID = $user->id;
if ($myID == 0) {
?>
<div id="registerContainer">
<span>Registracija</span><em></em>
<div style="clear:both"></div>
<div id="registerBox">
<form id="member-registration" action="<?php echo JRoute::_('index.php?option=com_users'); ?>" method="post" class="form-validate">
<fieldset id="reg-body" class="userdata">
<div class="reg-field">
<label for="jform_name" id="jform_name-lbl">
Ime i prezime:
</label>
</div>
<div style="float:left;">
<input type="text" maxlength="50" class="inputbox required" value="" size="40" id="jform_name" name="jform[name]"/><br/>
Molimo Vas da unesete stvarno ime i prezime!
</div>
<div style="clear:both;"></div>
<div style="height: 7px;"></div>
<div class="reg-field">
<label for="jform_username" id="jform_username-lbl">
Korisničko ime:
</label>
</div>
<div style="float:left;">
<input type="text" maxlength="25" class="inputbox required validate-username" value="" size="40" name="jform[username]" id="jform_username"/>
</div>
<div style="clear:both;"></div>
<div class="reg-field">
<label for="jform_password1" id="jform_password1-lbl">
Lozinka:
</label>
</div>
<div style="float:left;">
<input type="password" value="" size="40" name="jform[password1]" id="jform_password1" class="inputbox required validate-password"/>
</div>
<div style="clear:both;"></div>
<div class="reg-field">
<label for="jform_password2" id="jform_password2-lbl">
Potvrdite lozinku:
</label>
</div>
<div style="float:left;">
<input type="password" value="" size="40" name="jform[password2]" id="jform_password2" class="inputbox required validate-password"/>
</div>
<div style="clear:both;"></div>
<div class="reg-field">
<label for="jform_email1" id="jform_email1-lbl">
E-mail:
</label>
</div>
<div style="float:left;">
<input type="text" maxlength="100" class="inputbox required validate-email" value="" size="40" name="jform[email1]" id="jform_email1"/>
</div>
<div style="clear:both;"></div>
<div class="reg-field">
<label for="jform_email2" id="jform_email2-lbl">
Potvrdite e-mail:
</label>
</div>
<div style="float:left;">
<input type="text" maxlength="100" class="inputbox required validate-email" value="" size="40" name="jform[email2]" id="jform_email2"/>
</div>
<div style="clear:both;"></div>
<br/>
<font color = "#FF0000">Sva polja su obavezna!</font><br/>
<br/>
<button type="submit" class="button validate">Registracija</button>
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="registration.register" />
<?php echo JHtml::_('form.token');?>
</fieldset>
</form>
</div>
</div>
<?php
}
?>
I'm sorry if doesn't come out as a code block but the instructions are unclear. Anyhow - what I'd like to do is add a text field before the Submit button which will have something like a "What is 3 plus 2" label in front of it, and the submit won't work if the answer is incorrect. Is there any way to do this without editing Joomla core files?
You could user jQuery to add your label and input elements to the page. Then bind a .click() listener to the submit button that checks the validity of your answer before the form can be submitted. Do not that this is not a very secure bot checking solution. To add an extra level of security you might consider changing the 2 and 3 to two and three and also perhaps alternate between plus, minus, multiply and divide and store the answers and question combos in your Joomla session instead of calculating it all in JS.

Resources