Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Component b:breadcrumbs and Fix to selectOneMenu with converter #919

Merged
merged 27 commits into from
Mar 10, 2018

Conversation

mtvweb
Copy link

@mtvweb mtvweb commented Mar 5, 2018

This pull request contains the following changes:

  1. New Component b:breadcrumbs

Example:

<b:breadcrumbs>
  <b:navLink ....>
  <b:navCommandLink ...>
</b:breadcrumbs>
  1. Fix to b:selectOneMenu with Converter. Tested with
    (Example taken from : https://memorynotfound.com/using-custom-converter-for-hselectonemenu/)
public class Beer {

    private Integer id;
    private String brand;

    public Beer(Integer id, String brand) {
        this.id = id;
        this.brand = brand;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }
}
@Named
@ViewScoped`
public class BeersBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3192521384162408966L;
	private Beer selectedBeer;
	private List<Beer> beers;

	public BeersBean() {
	}
	
	@PostConstruct
	public void _init() {
		beers = new ArrayList<Beer>();
		beers.add(new Beer(10, "La Chouffe"));
		beers.add(new Beer(20, "Stella Artois"));
		beers.add(new Beer(30, "Westmalle Trippel"));
	}

	public Beer getSelectedBeer() {
		return selectedBeer;
	}

	public void setSelectedBeer(Beer selectedBeer) {
		System.out.println("set:" + selectedBeer);
		this.selectedBeer = selectedBeer;
	}

	public List<Beer> getBeers() {
		return beers;
	}

	public void setBeers(List<Beer> beers) {
		this.beers = beers;
	}

	public Beer getBeer(Integer id) {
		if (id == null) {
			throw new IllegalArgumentException("no id provided");
		}
		for (Beer beer : beers) {
			if (id.equals(beer.getId())) {
				return beer;
			}
		}
		return null;
	}
}
@FacesConverter(value = "beerConverter")
public class BeerConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext ctx, UIComponent uiComponent, String beerId) {
        ValueExpression vex =
                ctx.getApplication().getExpressionFactory()
                        .createValueExpression(ctx.getELContext(),
                                "#{beersBean}", BeersBean.class);

        BeersBean beers = (BeersBean)vex.getValue(ctx.getELContext());
        return beers.getBeer(Integer.valueOf(beerId));
    }

    @Override
    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object beer) {
        return ((Beer)beer).getId().toString();
    }

}
  1. Enabled Option "hideNoSelectOption" for b:selectOneMenu

  2. Modified Loop in navLink, navCommandLink to find parent boots faces component

jens and others added 25 commits April 29, 2017 10:14
i.E.

<b:panel col-md="6" collapsible="false">
</b:panel>
Small hack, if there is no dot found in expression. i.E. 

<ui:param name="calculatedAge"
  value="#{ !empty ref ? util.getAgeAsString(ref.birthday) : '' }" />
<b:inputText id="ageDisplay" span="2"
value="#{ calculatedAge }" readonly="true" disabled="true"
renderLabel="true" label="Age" />
This fixes a wrong class assignment, if a dropmenu is added inside a ui:repeat as part of another DropMenu. Now the correct class dropdown-submenu will be assigned

<b:navBar ...>
	<b:navbarLinks >
		<b:dropMenu ....>
			<ui:repeat var="subDropMenu" value="#menuHandler.dropmenus}">
				<b:dropMenu value="#{ subDropMenu.displaylabel }" >
					....
				</b:dropMenu>
			</ui:repeat>
		</b:dropMenu>
	</ui:repeat>
</b:navbarLinks>
Fix wrong display of panel collapse icon, if panel header contains a link

<b:panel collapsible="false">
  <f:facet name="heading">
    <i class="fa fa-battery-three-quarters" style="padding-right:20px" />
    <h:outputText value="Battery charge left: 75% " />
   <b:link style-class="some-class" onclick="alert('clicked!'); return false;" value="Click this link to show an alert box." />
    <b:badge style="margin-left:10px; background-color:#5cb85c" value="good"  />
  </f:facet>
....
</b:panel>
<b:selectOneMenu value="#{ vereinSession.verein }">
        <ui:remove>v is entity referencing a record of the table verein</ui:remove>
	<f:selectItems value="#{ managerVerein.list() }" var="v"
		itemValue="#{v}" itemLabel="#{ v.name }" />
</b:selectOneMenu>
Enables including subcomponents inside i.E. h:panelGroup or omnifaces Tree elements ....
Added attribute hideNoSelectionOption and noSelectionOption support for SelectOneMenu
New Component b:breadcrumbs
@chongma
Copy link
Collaborator

chongma commented Mar 6, 2018

Thanks looks good! This fixes converters on selectOneMenu. I will try to test it shortly

@stephanrauh
Copy link
Collaborator

@chongma If you'd like to merge the PR, go ahead! I've briefly scanned the changes, and I've exchanged a couple of e-mails with @mtvweb, so I'm positive we can merge the PR without further ado. But still, it has to be tested. What's your time-table?

@chongma
Copy link
Collaborator

chongma commented Mar 7, 2018

I pulled @mtvweb fork master and tried it with my converter test project but there were errors. It said f:converter was not allowed as child of b:selectOneMenu. I removed that part and the page rendered badly. Looking at html it had bootsfaces namespace in the main html tags. It may be that I am doing something wrong. I was going to take another look today

@chongma
Copy link
Collaborator

chongma commented Mar 7, 2018

first error was javax.faces.view.facelets.TagException: /converter.xhtml at line 68 and column 54 <f:converter> Parent not composite component or an instance of ValueHolder: javax.faces.component.html.HtmlForm@7205c2d4 org.apache.myfaces.view.facelets.tag.jsf.ConverterTagHandlerDelegate.apply(ConverterTagHandlerDelegate.java:100) and as i said the bootsfaces namspace is in the html tag
2018-03-07 12 21 33 pm
and then it looks like this
2018-03-07 12 22 31 pm
whereas with 1.2.0 stable it looks like this
2018-03-07 12 24 49 pm
should the @mtvweb master fork work similarly to the bootsfaces master branch?

@mtvweb
Copy link
Author

mtvweb commented Mar 7, 2018

Added my test classes, xhtml and build bootsfaces.jar as a zip file.

ConvertTest.zip

jens added 2 commits March 7, 2018 15:23
Fixed comments
Added mavenfiles generated by gradlew
@chongma
Copy link
Collaborator

chongma commented Mar 7, 2018

yes it works with the packaged jar. the converter also seems to be working which is awesome

@stephanrauh
Copy link
Collaborator

@chongma Can we merge the PR? I'm a bit confused because your comments seem to indicate that the merged version doesn't work, while the binary version Jens sent to you does work. Did I get this right?

@chongma
Copy link
Collaborator

chongma commented Mar 9, 2018

@stephanrauh I struggled with the forked project but the zipped jar worked fine. Is there some way i can clone and test the PR before merge? Otherwise we can just merge and see what happens?

@mtvweb
Copy link
Author

mtvweb commented Mar 9, 2018

I‘ve build my file from mtvweb Master with

gradlew build
mvn install

Meanwhile i‘ve added the mavenfiles generated by gradle too, but these only affects mainly css files.

@mtvweb mtvweb closed this Mar 9, 2018
@mtvweb
Copy link
Author

mtvweb commented Mar 9, 2018

BTW: It seems that the select2 files are disappearing somewhere during the gradle / mvn build

@mtvweb mtvweb reopened this Mar 9, 2018
@mtvweb
Copy link
Author

mtvweb commented Mar 9, 2018

Sorry, it seems that GitHub is not working properly with iPhone Safari. Some strange things are happen there. (Closing the pull request, without ever pushing the close button, etc..)

@stephanrauh stephanrauh merged commit 77f9510 into TheCoder4eu:master Mar 10, 2018
@stephanrauh
Copy link
Collaborator

@chongma I had the same difficulties with GitHub. I followed the instructions to merge the PR locally. Git insisted an merging the changes and committing a merge commit to the branch of Jens. In the end, I did just this and checked the files individually.

stephanrauh added a commit to TheCoder4eu/BootsFacesWeb that referenced this pull request Mar 10, 2018
@stephanrauh
Copy link
Collaborator

I've merged the PR and added the beer demo to the showcase. I just wonder if we should add some Spanish, Italian, and German beer brands :).

@stephanrauh
Copy link
Collaborator

I've also fixed the gradle build. Now it includes the select2 files. Thanks for pointing this out, @mtvweb
.

stephanrauh added a commit to TheCoder4eu/BootsFacesWeb that referenced this pull request Mar 10, 2018
@stephanrauh
Copy link
Collaborator

I've added a documentation page for the breadcrumb component. @mtvweb Do you have any suggestion what to add to the page?

BTW: I'll add the reference section later. It's generated automatically, but currently I've got the wrong version of the plugin installed, so it can only generate code for BootsFaces 2.

stephanrauh added a commit to TheCoder4eu/BootsFacesWeb that referenced this pull request Mar 10, 2018
stephanrauh added a commit that referenced this pull request Mar 10, 2018
stephanrauh added a commit that referenced this pull request Mar 10, 2018
@mtvweb
Copy link
Author

mtvweb commented Mar 16, 2018

In fact it's only another kind of a link list, like b:listLinks, b:navLinks, b:tabLinks or b:pillLinks. So I don't see nothing special to document. A standard navLink or navCommandLink should render well in the new component. Separater will result in an empty entry "/ /"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants