I am able to use webflow with ajax using POST, but not with GET.
I have a parent object at the top of my page. I have a list of potential children at the bottom of the page. The user selects the "add" link by a potential child to add to the parent.
Full formed html is as follows:
<tr>
<td>Add</td>
<td>Advanced French</td>
</tr>
<tr>
<td>Add</td>
<td>Algebra One</td>
</tr>
However, this refreshes the whole page. How do I make this an ajax call so I just refresh the one fragment (i.e., the parent's specified children).
NOTE: My question is about forming the call to webflow. I know how to render the result
Here's the answer to the question asked here. I am not sure whether the javascript params fragments argument is necessary as the fragments to render are specified in webflows "render fragments." The function seems to work without this argument.
<table id="bodyInnerTable"
style="border: 1px solid #007589; width: 100%; vertical-align: top">
<tr>
<td id="bodyMainCellHead" colspan="2" th:text="#{label.availabletuts}">Name</td>
</tr>
<!-- Iterate through the children (retrieved from db and held in bean as TreeMap)
Each <a> tag must have a unique th:id. The name attribute applies to all children in list
-->
<tr th:each="tut : ${vwNewTestType.tutMap}" th:if="${vwNewTestType.tutMap.size() > 0}">
<td><a th:id="${tut.value}" name="addtutname"
th:href="#{'~' + ${flowExecutionUrl}(_eventId=addtut, tutid=${tut.value},tutname=${tut.key})}">Add</a></td>
<td th:text="${tut.key}">id</td>
</tr>
</table>
<!-- dojo .forEach will then allow for identification of which element is clicked and the webflow transition on=""addtut" is called-->
<script type="text/javascript">
dojo.query("a[name=addtutname]").forEach(function(element)
{
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: element.id,
event: "onclick"
//params: { fragments:"s2,s4"}
}))
});
</script>
Related
I want to append an element to a specific element when the user clicks the button. The scenario goes like this. Is there another way to deal with that kind of problem?
<table>
<tbody>
<tr>
<td>
One
<button>delete</button>
<button x-on:click="edit(passIdToFunc)">edit</button>
</td>
</tr>
<tr id="one" style="display: hidden"></tr>
<!-- append x-teleport dom node to here when current value is id = one -->
<tr>Two</tr>
<tr id="two" style="display: hidden"></tr>
<tr>Three</tr>
<tr id="three" style="display: hidden"></tr>
...
</tbody>
</table>
<!--
For the initial render, or if there is no table data,
I would like to append it to somewhere else with display none.
-->
<template x-teleport="computedString">
...
</template>
This looks like the wrong usage for x-teleport, though it's not clear from the example where you are teleporting to. You can just use x-show to toggle display:none if that's what you're looking for.
here is the xpath I am using
//tr[#id = 'inputSavePaymentAccounts']/descendant::input[#type = 'checkbox' and #name = 'payAck' and #tabindex = '10'
here is how I can get it to check the checkbox
jQuery('.payAck').prop('checked', true)
here is the checking account html that is inside an iframe
<tr id="inputSavePaymentAccounts" class="savePaymentAccounts" style="display: table-row;">
<td class="addCCLabel" style="padding-top: 15px;">Save this Payment Method</td>
<td style="padding-top: 15px;">
<input class="payAck" type="checkbox" onchange="friendlyNameShow()" name="payAck" tabindex="10">
</td>
</tr>
here is the credit card html that is inside the same iframe
<tr id="inputSavePaymentAccounts" class="savePaymentAccounts" style="display: table-row;">
<td class="addCCLabel" style="padding-top: 15px;">Save this Payment Method</td>
<td style="padding-top: 15px;">
<input class="payAck" type="checkbox" onchange="friendlyNameShow()" name="payAck" tabindex="25">
</td>
</tr>
The main issue is that when i use:
jQuery('.payAck').prop('checked', true)
it checkmarks the checkbox however, at the time the checkbox is checked I am suppose to see a text box display, which is not happening with the above jquery. I was hoping the execution of xpath would solve this
see these for a more clearer picture
image of checkbox http://prnt.sc/c12b1p
image of checkbox when it is checked with text box displaying (need this to happen) http://prnt.sc/c12b7q
First of all, I would recommend you remove the inline javascript. Your primary selector in this case is a class and the class is assigned to 2 elements (at least from what I see in your example). When you check the checkbox using jQuery with the class selector, it is going to trigger all the elements that belong to that class and I don't think that is what you intend to do. Also, using click() will work, but that will cause friendlyNameShow() to be called twice and you will need to check the state of the checkbox since you are not explicitly checking/un-checking it. Try using and Id instead.
The following is the DOM details:
<div id: "abc_440"
<table class = "listtable" >
<tbody>
<tr>
<td id = "someid" >
<td class = 'someclass_item"> This is Text </td>
<td class = 'someclass_button">
< a > Add </a>
</td>
</tr>
</tbody>
</table>
</div>
I need to click on 'Add' for particular text at "This is Text". I have to use div with ID (abc_440)to locate the corresponding table as there are may divs with this same dom layout. but index at div ID (for example 440) keeps changing to random number. How do I handle it in general ?
Please help.
I think that what you want to do is very similar to the previous Watir question.
Given that the id is randomly generated, it does not sounds like a good way of finding the link. You will likely need to use the text of the same row.
Assuming that the "This is Text" is unique (as you said you want to find the Add link for it), you can find that td, go to the parent row and then get the link.
b.td(:text => 'This is Text').parent.link.click
If you need to ensure that the text is in the second column, then you can do:
b.trs.find{ |tr|
tr.td.exists? and tr.td(:index => 1).text == 'This is Text'
}.link.click
The tr.td.exists? is added in case some of your rows do not have any tds (example a header row), which would cause an exception when checking the second criteria.
Don't mix quotes in HTML tags. id: doesn't work. <td>s should rarely be empty. The Add button should be a button, not an <a>nchor element. Buttons only work in <form>s.
<form id="abc_440" action='someURI'> <!-- The handler for the button. -->
<table class="listtable">
<tbody>
<tr>
<td id = "someid">
<!-- What goes here? -->
</td>
<td class='someclass_item'>
This is Text
</td>
<td class='someclass_button'>
<button name='add'>Add</button>
</td>
</tr>
</tbody>
</table>
</form>
You should be able to find the button through its name attribute, add, and through the form's id attribute, abc_440. Who generates the ids?
Once you have the problem of finding the add button solved, and figuring out where the form's id comes from, please then stop using tables for formatting. There's no need for that. Learn about <form>s, <fieldset>s, <legend>s, and <label>s. I doubt you need the *some_id* part, the text part should probably be a <label>, and you can use CSS to format your <label>s as:
label {
width: 150px;
float: left;
}
fieldset p {
clear: left;
}
I have a iterator which goes through a list and create their name and for each of them a button. I want when the user click the button put the same name that has been clicked in the session
This is my code
<s:iterator value="packageCities" status="portStatus">
<tr>
<td>
<s:property value="cityName" />
</td>
</tr>
<s:if test="%{status == 0}">
<tr>
<td>
<s:submit method="open" align="center" value="" cssStyle="background: transparent url(image/open.png) no-repeat center top; border: 0px; width: 150px; height: 30px;" >
<s:set name="button" value="cityName" scope="session"/>
</s:submit>
</td>
</tr>
</s:if>
</s:iterator>
But The problem is it only sets the last property , And it doesn't set it when user clicked the button! so it like when its creating the button it is putting the cityName in the session! But I only want to put different thing in session by clicking different buttons!
Can Any Body Help?
There are two solutions:
Submit the value along with the form (a hidden field may be used for this purpose). Then set the session variable in the action class.
Make a synchronous ajax request to set the session value onclick of the submit buttons.
As Dave mentioned when the jsp is loaded the values are already set you cannot change them from client side.
EDIT
Ok, as you requested, here is a basic idea of the first method. The idea is to set the id of submit buttons with the respective cityName and then onclick of button call a javascript function to set a hidden field's value with the clicked button's id (i.e. its cityName)
<s:form>
<s:hidden id="value_to_submit" name="value_to_submit"/>
<s:iterator value="packageCities" status="portStatus"><s:form>
....
<s:if test="%{status == 0}">
<tr>
<td>
<s:submit id="%{cityName}" onclick="set_hidden_value(this.id)" method="open" align="center" value="" cssStyle="background: transparent url(image/open.png) no-repeat center top; border: 0px; width: 150px; height: 30px;" >
</s:submit>
</td>
</tr>
</s:if>
</s:iterator>
</s:form>
Javascript
function set_hidden_value(myvalue){
document.getElementById("value_to_submit").value=myvalue;
}
Now you can capture the value of the variable value_to_submit in your action class and set the session variable there.
Two issues.
One, the name is always the same, so you're always setting the same property.
Two, and more important, the JSP has executed all the JSP tags by the time it gets to the browser--this is not how you set a session variable on a button click.
The session variable needs to be set in the action handling the submit.
In IE6, the expander graphic for the root node in the table is not showing up. If I position the mouse in the correct spot next the the root nodes text I can actually click the expander.
The expander does show up for all child nodes.
The odd thing is the examples at the TreeView site show the root expander image in IE6. I can't see the difference between the examples code and mine. I did a side by side comparison of the CSS for the elements in question and nothing jumps out at me.
I have no extra styling than the stylesheet that came with the plug-in provides.
<script type="text/javascript">
$(document).ready(function() {
$("#tree").treeTable();
});
</script>
-
<body>
<table id="tree">
<tr id="node-1">
<td>Parent</td>
</tr>
<tr id="node-2" class="child-of-node-1">
<td>Child</td>
</tr>
<tr id="node-3" class="child-of-node-2">
<td>Child</td>
</tr>
</table>
</body>
Just for reference, since i ran into this trouble too...
The first parent image doesn't show because the space for the image to be is too small, so the treetable.css and treetable.js need to be modified.
In jquery.treeTable.js, change the line:
cell.prepend('<span style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></span>');
To:
cell.prepend('<span class="expander"></span>');
And in jquery.treeTable.css, add the last two lines (margin-left and padding-left) to ".treeTable tr td .expander":
.treeTable tr td .expander {
background-position: left center;
background-repeat: no-repeat;
cursor: pointer;
padding: 0;
zoom: 1; /* IE7 Hack */
margin-left: -3px;
padding-left: 15px;}
°°°°°°°°°°°°°°°°°°°°°°°°°
I didn't Modify the Code, the above tip was taken from:
http://javathoughts.capesugarbird.com/2009/03/jquery-tree-table-for-wicket.html
-VicSan.
I agree with VicSan solution, although I prefer not to modify TreeTable source code (so I can upgrade it to future versions without need to make again my changes inside the new code). So I suggest you to simply add a padding-left in the style attribute of the first cell of the first row of your tree-table (the root):
<body>
<table id="tree">
<tr id="node-1">
<td style="padding-left: 19px">Parent</td>
</tr>
<tr id="node-2" class="child-of-node-1">
<td>Child</td>
</tr>
<tr id="node-3" class="child-of-node-2">
<td>Child</td>
</tr>
</table>
</body>
I put 19px because it's the default, but, if you specified another value in the indent option (when you create the tree-table with .treeTable(...)), put that one.